Hello,
I'm trying to create code so that when a user enters an ID in A2, the city will autopopulate in B2, and the person's name associated with that ID will autopopulate in C2.
[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD]ID (A2)[/TD]
[TD]City (B2)[/TD]
[TD]Person (C2)[/TD]
[/TR]
[TR]
[TD]N11111[/TD]
[TD]Airville[/TD]
[TD]John Doe[/TD]
[/TR]
</tbody>[/TABLE]
?? Does it matter whether I list multiple/consecutive IF statements or should I use IF/ELSEIF statements?
I don't see how listing consecutive IF statements will be a problem with my code and would like to see if someone can tell me what would be the correct way to use IF statements re: the code below.
I appreciate your help!
<tbody style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline;">
[TD="class: votecell"]
[/TD]
[TD="class: answercell"][/TD]
</tbody>
I'm trying to create code so that when a user enters an ID in A2, the city will autopopulate in B2, and the person's name associated with that ID will autopopulate in C2.
[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD]ID (A2)[/TD]
[TD]City (B2)[/TD]
[TD]Person (C2)[/TD]
[/TR]
[TR]
[TD]N11111[/TD]
[TD]Airville[/TD]
[TD]John Doe[/TD]
[/TR]
</tbody>[/TABLE]
?? Does it matter whether I list multiple/consecutive IF statements or should I use IF/ELSEIF statements?
I don't see how listing consecutive IF statements will be a problem with my code and would like to see if someone can tell me what would be the correct way to use IF statements re: the code below.
I appreciate your help!
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim wkbk As Workbook
Dim wksht As Worksheet
Dim node As String
Set wkbk = ActiveWorkbook
Set wksht = ActiveSheet
node = Range("A2").Value
[B]'Clear B2 if A2 is blank[/B]
If node = "" Then
Range("B2").Value = ""
End If
[B]'MAIN CODE
' If value entered in A2 starts with N then add Airville to B2 [/B]
If node Like "N*" Then
Range("B2").Value = "Airville
End If
[B]' If value entered in A2 starts with E then add Aleive to B2 [/B]
If node Like "E*" Then
Range("B2").Value = "Aleive"
End If
[B]'Etc., etc. 31 more times
[/B]End Sub
<tbody style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline;">
[TD="class: votecell"]
[TD="class: answercell"][/TD]
</tbody>