I am trying to Find and Replace values in a column from a different Worksheet within the same Workbook. If I have the command button on the same worksheet as the data then this works.
I really want the command button on a different worksheet from the data. I have tried multiple attempts but still get a Run-time error '1004': Select method or Range class failed on the line "Columns("C:C").Select
I am guessing I am not seting the range correctly
I have also tried variations along this line and fails at the same line:
Thank you for any help.
You don't know what you don't know...
Code:
Sub cmdFindReplaceLocation_Click()
Columns("C:C").Select
Selection.Replace What:="5WS*", Replacement:="5WS", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub
I really want the command button on a different worksheet from the data. I have tried multiple attempts but still get a Run-time error '1004': Select method or Range class failed on the line "Columns("C:C").Select
I am guessing I am not seting the range correctly
Code:
Sub cmdFindReplaceLocation_Click()
'
' Recorded macro
'
Sheets("STEWARDSHIP").Select
Columns("C:C").Select
Selection.Replace What:="IC/4WMICU*", Replacement:="4WMICU", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub
I have also tried variations along this line and fails at the same line:
Code:
Sub cmdFindReplaceLocation_Click()
Dim wks as Worksheet
Set wks = Worksheets("STEWARDSHIP")
With wks
Columns("C:C").Select
Selection.Replace What:="IC/4WMICU*", Replacement:="4WMICU", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End With
End Sub
Thank you for any help.
You don't know what you don't know...