I'm trying to create a simple macro that changes header name. Example: header name: vcom#, run macro will change to itemnumber. I want the macro to check the first row for vcom# and change it. The header vcom# will never be in the same cell, it will vary worksheet to worksheet.
When I run the macro, it changes vcom# to itemnumber but stops and gives me an error message 91.
Here is the code:
Sub Macro4()
'
' Macro4 Macro
'
'
ActiveCell.Rows("1:1").EntireRow.Select
Selection.Find(What:="vcom#", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Replace What:="vcom#", Replacement:="itemNumber", LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.FindNext(After:=ActiveCell).Activate
ActiveCell.Offset(0, -3).Range("A1").Select
End Sub
Can anyone help.