I am trying to get my if statement to work but it is not going how i want it, i want it that if the first name value is FRS then cNum and gNum go in those columns (3 and 4), if it is not then go to column 4 for cNum and 3 for gNum
If shtList.Cells(Index + 4, 11).value = "Yes" Then
firstName = rng(i, 11).value
lastName = rng(i, 10).value
End If
If firstName = "FRS" Then
shtMap.Cells(lastRow, 3).value = cNum
shtMap.Cells(lastRow, 4).value = gNum
Else
shtMap.Cells(lastRow, 4).value = cNum
shtMap.Cells(lastRow, 3).value = gNum
End If
below is the code over all
Sub lookup(Index As Integer, cNum As Integer, EStart As Integer, lookupP As Worksheet)
Dim lastRow, i As Integer
Dim rng As Range
Dim checkBoolCat As Boolean
Dim splitList As Variant
Dim item As Variant
If lookupP.Name = "shtTags_1" Then
Set rng = shtTags_1.ListObjects("reference_1").DataBodyRange
Else
Set rng = shtTags.ListObjects("reference").DataBodyRange
End If
Dim lastName, firstName, As String
Dim gNum, sgNum As Integer
Dim val As Variant
If E_Start = 1 Then
lastRow = 3
Else
lastRow = shtMap.Cells(1000000, 1).End(xlUp).Row + 1
End If
For i = 1 To rng(, 1).Rows.count
firstName = rng(i, 2).value
lastName = rng(i, 1).value
gNum = 0
sgNum = 0
val = shtList.Cells(Index + 4, rng(i, 4).value) _
.value
If shtList.Cells(Index + 4, 11).value = "Yes" Then
firstName = rng(i, 11).value
lastName = rng(i, 10).value
End If
If firstName = "FRS" Then
shtMap.Cells(lastRow, 3).value = cNum
shtMap.Cells(lastRow, 4).value = gNum
Else
shtMap.Cells(lastRow, 4).value = cNum
shtMap.Cells(lastRow, 3).value = gNum
End If
lastRow = shtMap.Cells(1000000, 1).End(xlUp).Row + 1
Next i
End Sub
If shtList.Cells(Index + 4, 11).value = "Yes" Then
firstName = rng(i, 11).value
lastName = rng(i, 10).value
End If
If firstName = "FRS" Then
shtMap.Cells(lastRow, 3).value = cNum
shtMap.Cells(lastRow, 4).value = gNum
Else
shtMap.Cells(lastRow, 4).value = cNum
shtMap.Cells(lastRow, 3).value = gNum
End If
below is the code over all
Sub lookup(Index As Integer, cNum As Integer, EStart As Integer, lookupP As Worksheet)
Dim lastRow, i As Integer
Dim rng As Range
Dim checkBoolCat As Boolean
Dim splitList As Variant
Dim item As Variant
If lookupP.Name = "shtTags_1" Then
Set rng = shtTags_1.ListObjects("reference_1").DataBodyRange
Else
Set rng = shtTags.ListObjects("reference").DataBodyRange
End If
Dim lastName, firstName, As String
Dim gNum, sgNum As Integer
Dim val As Variant
If E_Start = 1 Then
lastRow = 3
Else
lastRow = shtMap.Cells(1000000, 1).End(xlUp).Row + 1
End If
For i = 1 To rng(, 1).Rows.count
firstName = rng(i, 2).value
lastName = rng(i, 1).value
gNum = 0
sgNum = 0
val = shtList.Cells(Index + 4, rng(i, 4).value) _
.value
If shtList.Cells(Index + 4, 11).value = "Yes" Then
firstName = rng(i, 11).value
lastName = rng(i, 10).value
End If
If firstName = "FRS" Then
shtMap.Cells(lastRow, 3).value = cNum
shtMap.Cells(lastRow, 4).value = gNum
Else
shtMap.Cells(lastRow, 4).value = cNum
shtMap.Cells(lastRow, 3).value = gNum
End If
lastRow = shtMap.Cells(1000000, 1).End(xlUp).Row + 1
Next i
End Sub