View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Can You Change A CommandButton Code Using A Macro?

You can using code such as that shown at Chip Pearson's site
http://www.cpearson.com/excel/vbe.htm

However, it would seem easier to me to use a sheet level name and just
change the definition in the new sheet.

Range("B1").Name = "' & Activesheet.Name & "'!Rng1"

then in the code refer to it as

me.Range("Rng1")

After you copy the sheet, with the new sheet active run this command

Range("E1").Name = "' & Activesheet.Name & "'!Rng1"

Now, the button code in the new sheet will refer to E1.

--
Regards,
Tom Ogilvy


"Donna" wrote in message
om...
I have a macro that copies a sheet and renames it to Sheet B.
Sheet B already contains 2 buttons that reference a cell range "B1" in
the button code.
I want to change that cell range to "E1" using a macro.

Is this possible??
Thanks for any help that can be given.