VBA Question (Run Time Error 1004)?

MichaelRSnow

Active Member
Joined
Aug 3, 2010
Messages
409
Any help with why I am getting the following run time error

'Run Time Error 1004'
Select method of range class failed

my code is

Private Sub CommandButton1_Click()
'In the availability column (G), change text Intermediary (MSO) to Intermediary without (MSO)'

Application.ScreenUpdating = False

Sheets("Sheet1").Select
Columns("G:G").Select
Selection.Replace What:="Intermediary (MSO)", Replacement:="Intermediary", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

Application.ScreenUpdating = True
Range("A1").Select
End Sub
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Try not using Select to begin with...

Try
Rich (BB code):
Private Sub CommandButton1_Click()
'In the availability column (G), change text Intermediary (MSO) to Intermediary without (MSO)'

Application.ScreenUpdating = False

Sheets("Sheet1").Columns("G:G").Replace What:="Intermediary (MSO)", Replacement:="Intermediary", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

Application.ScreenUpdating = True
End Sub
<!-- / message -->

Hope that helps.
 
Upvote 0

Forum statistics

Threads
1,224,505
Messages
6,179,151
Members
452,891
Latest member
JUSTOUTOFMYREACH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top