Hello,
I think this is probably a very simple solution for all those with a little VBA knowledge (which obviously rules me out). Any help would be much appreciated....
I'm setting up an orderbook, much of which requires data entry (until a more appropriate solution is in place).
In the meantime, what I'd like to happen is that when a name is selected (from a dropdown) in cell Q4 that a lookup formula automatically runs in cells U4 and W4 to return data from to columns of a table. I've put the following code in place but it doesn't allow me to go back into Q4 as the macro runs each time I select the cell.
Effectively, I want the user to be able to go back into the cell as required and for the macro only to run if the value entered in the cell changes (be this from blank to an entry or from one entry to another).
I suspect this code could be shortened down somewhat, but here is what I have so far.....
Thanks in advance
David
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$Q$4" Then
Call getdata
End If
End Sub
Sub getdata()
Range("U4").Select
ActiveCell.FormulaR1C1 = "=IFERROR(VLOOKUP(R4C17,SHOPLOOKUP,2,FALSE),"""")"
Range("W4").Select
ActiveCell.FormulaR1C1 = "=IFERROR(VLOOKUP(R4C17,SHOPLOOKUP,3,FALSE),"""")"
Range("U4").Select
Selection.Copy
Range("U4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("W4").Select
Selection.Copy
Range("W4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("S4").Select
End Sub
I think this is probably a very simple solution for all those with a little VBA knowledge (which obviously rules me out). Any help would be much appreciated....
I'm setting up an orderbook, much of which requires data entry (until a more appropriate solution is in place).
In the meantime, what I'd like to happen is that when a name is selected (from a dropdown) in cell Q4 that a lookup formula automatically runs in cells U4 and W4 to return data from to columns of a table. I've put the following code in place but it doesn't allow me to go back into Q4 as the macro runs each time I select the cell.
Effectively, I want the user to be able to go back into the cell as required and for the macro only to run if the value entered in the cell changes (be this from blank to an entry or from one entry to another).
I suspect this code could be shortened down somewhat, but here is what I have so far.....
Thanks in advance
David
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$Q$4" Then
Call getdata
End If
End Sub
Sub getdata()
Range("U4").Select
ActiveCell.FormulaR1C1 = "=IFERROR(VLOOKUP(R4C17,SHOPLOOKUP,2,FALSE),"""")"
Range("W4").Select
ActiveCell.FormulaR1C1 = "=IFERROR(VLOOKUP(R4C17,SHOPLOOKUP,3,FALSE),"""")"
Range("U4").Select
Selection.Copy
Range("U4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("W4").Select
Selection.Copy
Range("W4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("S4").Select
End Sub