Find Button

FlashGordy

New Member
Joined
Mar 23, 2011
Messages
8
Afternoon again guys.

I was wondering how one would go about adding a button into a a sheet which, when clicked would find and replace a specific character or value, on another sheet, without requiring confirmation.

Thanks
Gordon
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Hi there,

Add your button using the Control Toolbox, double click on it and paste this in:

Code:
Private Sub CommandButton1_Click()
    lRow = Sheets("[U][B]Sheet2[/B][/U]").Range("[U][B]A1[/B][/U]").End(xlDown).Row
    Sheets("[B][U]Sheet2[/U][/B]").Range("[U][B]A1:A[/B][/U]" & lRow).Replace What:="[U][B]b[/B][/U]", Replacement:="[U][B]s[/B][/U]"
End Sub

Change the bold and underlined bits to whatever you wish.
 
Upvote 0
Hi James

I'm using Excel for Mac. So I'm guessing I right click on the button I created and go to "Assign Macro"? It creates a Macro called "Button1_Click" but will not let me paste anything underneath?

Gordon
 
Upvote 0
Ah, erm... Not sure about Mac unfortunatly.

Try adding this to the module, instead of the click event:

Code:
Sub stuff()
    lRow = Sheets("Sheet2").Range("A1").End(xlDown).Row
    Sheets("Sheet2").Range("A1:A" & lRow).Replace What:="b", Replacement:="s"
End Sub
and then assigning the button to 'stuff' - Change the name if you like.
 
Upvote 0
I've tried it on a windows machine too, and I'm still unable to edit the macro. I'm kinda new to the whole macro thing, so don't know if I'm just doing something stupid.

How does one "add to the module" and "assign a button"?
 
Upvote 0
Alt + F11 to open the VB Editor. Go Insert --> Module and then paste the code provided from James

George

I've tried it on a windows machine too, and I'm still unable to edit the macro. I'm kinda new to the whole macro thing, so don't know if I'm just doing something stupid.

How does one "add to the module" and "assign a button"?
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,285
Members
452,902
Latest member
Knuddeluff

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