I'm trying to create what I believe to be a simple loop to my VBA code, but unfortunately I don't know enough about VBA to create it, so I'm just posting the code I have and am hoping somebody could tell me what I need to do to loop the code. I need the loop to continue from column to column using the stock symbols that are in each row until I run out of stock symbols. All the stock symbols are in row 3, starting in column B.
Sub CopyReplace()
'
' CopyReplace Macro
'
'
Dim LstCo As Long, LstRw As Long
ActiveWindow.SmallScroll ToRight:=-2
Range("B5:B483").Select
Selection.Copy
Selection.End(xlToRight).Select
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveSheet.Paste
LstRw = Cells.Find("*", , xlValues, xlPart, xlByRows, xlPrevious, True).Row
LstCo = Rows("5:" & LstRw).Find("*", , xlValues, xlPart, xlByColumns, xlPrevious, True).Column
With Range(Cells(5, LstCo), Cells(LstRw, LstCo))
.Replace What:="A.", Replacement:=Cells(3, LstCo).Value, _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=True
End With
ActiveWorkbook.Save
End Sub
Any help to get the above code to loop until there are no more stock symbols in row 3 is much appreciated!
Sub CopyReplace()
'
' CopyReplace Macro
'
'
Dim LstCo As Long, LstRw As Long
ActiveWindow.SmallScroll ToRight:=-2
Range("B5:B483").Select
Selection.Copy
Selection.End(xlToRight).Select
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveSheet.Paste
LstRw = Cells.Find("*", , xlValues, xlPart, xlByRows, xlPrevious, True).Row
LstCo = Rows("5:" & LstRw).Find("*", , xlValues, xlPart, xlByColumns, xlPrevious, True).Column
With Range(Cells(5, LstCo), Cells(LstRw, LstCo))
.Replace What:="A.", Replacement:=Cells(3, LstCo).Value, _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=True
End With
ActiveWorkbook.Save
End Sub
Any help to get the above code to loop until there are no more stock symbols in row 3 is much appreciated!