View Single Post
 
Old 08-17-2021, 04:52 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,103
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

You probably need something like the following, but if there are lots of these values as seems to be the case you would be better putting the codes and their values in an Excel worksheet and reading them from the worksheet.

Code:
Private Sub CommandButton2_Click()
Dim sVia As String
Dim lPK As String
    sVia = ComboVia.Text
    lPK = textPK.Value
    Select Case sVia
        Case Is = "A-68"
            If lPK > 81 And lPK < 85 Then
                Rellenar "termino", "Castejon"
                Rellenar "partido", "Tudela"
            End If
            If lPK > 84 And lPK < 99 Then
                Rellenar "termino", "Corella"
                Rellenar "partido", "Estella"
            End If
            If lPK > 98 And lPK < 113 Then
                Rellenar "termino", "Fontellas"
                Rellenar "partido", "Tafalla"
            End If
        Case Is = "NA-3010"
            If lPK > 20 And lPK < 25 Then
                Rellenar "termino", "Cortes"
                Rellenar "partido", "Tudela"
            End If
            If lPK > 24 And lPK < 35 Then
                Rellenar "termino", "Ribaforada"
                Rellenar "partido", "Tafalla"
            End If
            If lPK > 34 And lPK < 44 Then
                Rellenar "termino", "Novillas"
                Rellenar "partido", "Estella"
            End If
    End Select
lbl_Exit:
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote