Hi,
I am a vba newbie and am trying to replicate the below code for 25 rows (rows 7-31).
the code does a vlookup for certain cells dependant on data validation in another cell.
I am not familiar with loops in vba and was hoping someone could help me with that.
Any help would be greatly appreciated.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("F7") = "Yes" Then
If (Target.Address = "$H$7") Then
If Range("G7") = "" Then
MsgBox ("Column G cannot be blank if you selected yes.")
Range("F7").Select
Else
Range("H7").Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-1],'[abc.xlsx]0210 - IDDAs'!R1C3:R65536C11,3,FALSE)"
Range("I7").Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-2],'[abc.xlsx]0210 - IDDAs'!R1C3:R65536C11,5,FALSE)"
Range("J7").Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-3],'[abc.xlsx]0210 - IDDAs'!R1C3:R65536C11,6,FALSE)"
Range("K7").Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-4],'[abc.xlsx]0210 - IDDAs'!R1C3:R65536C11,8,FALSE)"
Range("L7").Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-5],'[abc.xlsx]0210 - IDDAs'!R1C3:R65536C11,9,FALSE)"
End If
Else
End If
Else
If (Target.Address = "$K$7") Then
Range("K7").Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-1],'[abc.xlsx]0210 - IDDAs'!R1C8:R65536C11,3,FALSE)"
Range("L7").Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-2],'[abc.xlsx]0210 - IDDAs'!R1C8:R65536C11,4,FALSE)"
Else
End If
End If
End Sub
Bookmarks