Hi all,
I'm trying to construct a macro to track sales of particular products by week. I have week numbers along the horizontal axis (in Row 4), and product numbers along the vertical axis (in Column A). I would like the macro to find the previous week number on the horizontal axis, and if there is a product number in column A for that row, perform the VLOOKUP. If there is not a product number in that row, I would like to advance to the next cell. This should continue until the "**" at the bottom of the sheet.
I can find the correct week number on the horizontal axis, but I think my Do loop is wrong - it's just advancing down the column without performing any VLOOKUPS.
Here's the code I've used:
Sub Macro1()
**the first part of the code finds the correct week in Row 4**
ActiveCell.Offset(2, 0).Activate
Do Until ActiveCell.Value = "**"
If IsNumeric(Cells(1, 1)) = True Then
ActiveCell.Formula = "=VLOOKUP(RC1,'SA021'!C2:C16,15,0)"
ElseIf IsNumeric(Cells(1, 1)) = False Then
ActiveCell.Offset(1, 0).Activate
End If
Loop
End Sub
Any help would be greatly appreciated!
Bookmarks