Hi there
I'm trying to create a Dynamic Range within a recorded Macro by editing the VBA that's already there.
I've searched around but none of the tutorials seem to fit my needs.
Am confused as to whether I need an 'offset' or DIM or End(xlUp) function and how to use it.
I simply need to add a VLKUP starting in cell Z13 but autofilled down to whichever row the data ends in Column Y. At the moment it adds it down to row 512 as that's where the original data ended upon recording. When I add data next time though, there may be more or less rows so I need to make this dynamic!
Here's my basic script..
Sub Clean1()
'
' Clean1 Macro
'
'
Range("Z12").Select
ActiveCell.FormulaR1C1 = "Destination Region"
Range("Z13").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(C[-23],LKUP!C[-24]:C[-23],2,0)"
Selection.AutoFill Destination:=Range("Z13:Z512")
Range("Z13:Z512").Select
Range("Y12").Select
End Sub
Many thanks in advance!
Melissa
I'm trying to create a Dynamic Range within a recorded Macro by editing the VBA that's already there.
I've searched around but none of the tutorials seem to fit my needs.
Am confused as to whether I need an 'offset' or DIM or End(xlUp) function and how to use it.
I simply need to add a VLKUP starting in cell Z13 but autofilled down to whichever row the data ends in Column Y. At the moment it adds it down to row 512 as that's where the original data ended upon recording. When I add data next time though, there may be more or less rows so I need to make this dynamic!
Here's my basic script..
Sub Clean1()
'
' Clean1 Macro
'
'
Range("Z12").Select
ActiveCell.FormulaR1C1 = "Destination Region"
Range("Z13").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(C[-23],LKUP!C[-24]:C[-23],2,0)"
Selection.AutoFill Destination:=Range("Z13:Z512")
Range("Z13:Z512").Select
Range("Y12").Select
End Sub
Many thanks in advance!
Melissa