How do I move this button to new sheet?

vllgv

Board Regular
Joined
Oct 27, 2010
Messages
206
Hello all,

I want to move this button from Sheet1 to Sheet2. Thank you for any tips?

Getting error 1004 "Application-defined" or "Object-defined" 1004 on line:
Worksheets("Sheet1").Range("F:AM").Select

Code:
Private Sub CommandButton3_Click()
Dim i As Long
Dim c As Range
Dim r As Range
For i = 2 To Worksheets("Sheet2").Cells(Rows.Count, "A").End(xlUp).Row
Set c = Worksheets("Sheet2").Range("A" & i)
    Worksheets("Sheet1").Range("F:AM").Select
    Selection.Replace What:=c.Value, Replacement:=c.Offset(, 1), LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False

Next i
End Sub
 
Last edited:

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

Forum statistics

Threads
1,203,546
Messages
6,056,035
Members
444,840
Latest member
RazzelDazel

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