View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default Assigning macro to button

Zak

Add the line Option Compare Text at the top of the module above your Sub

This tells the code to ignore case.


Gord Dibben MS Excel MVP


On Sun, 13 Jan 2008 09:33:01 -0800, Zak wrote:

Hi,

thanks this worked but the problem is it only works when i assign the macro
in the sheet with all the data. if i put the button in sheet 2, which is
empty and where i want the button to be it doesnt work! maybe i need to put
in a condition in the button code so that it works regardless of what sheet
its in. also i found because i put in a condition 'find GIS' (in upper case)
it only finds it if its in upper case, can i do it so the macro will find
this word regardless of the case its in?

thanks a lot.

"FSt1" wrote:

hi
sorry about the other post. hit the wrong button.
try this....

Private Sub CommandButton1_Click()
Call replace
End Sub

regards
FSt1
"Zak" wrote:

I have tried many times to add my macro to a button but it does not work. I
have tried both the control toolbox and the forms menu.

I am in design view when i create the button, double click it to show the
VBE, enter the below code, go back to the button coming out of design view
but nothing happens! not even an error. same when i do it via the forms menu,
i assign the button but nothing happens!!
(replace is my macros name.)

Private Sub CommandButton1_Click()
Run "replace"

End Sub

please help. thanks.