ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Command Button (https://www.excelbanter.com/excel-programming/293890-command-button.html)

jongdg

Command Button
 
This is probably a simple problem. There are certain macro's that
want to assign a command button to. I have no problem if the macr
functions within the sheet that contains the button. But, if the macr
calls for information contained within a different sheet, the macr
fails. The strange part is that these macro run fine if there no
assigned to a command button. But once the same macro code is copie
into the private sub of a command button, it fails

--
Message posted from http://www.ExcelForum.com


Dave Peterson[_3_]

Command Button
 
Two guesses.

#1. You're using xl97. Try changing the .takefocusonclick to False.
Or add: Activecell.activate (right near the top of your code)

#2. You didn't qualify your ranges.
If it's an unqualified range in a worksheet module, then it refers to the
sheet that owns the code:

behind sheet1:
worksheets("sheet2").select
range("a1").value = 99

that range("a1") refers to sheet1--not the activesheet.



"jongdg <" wrote:

This is probably a simple problem. There are certain macro's that I
want to assign a command button to. I have no problem if the macro
functions within the sheet that contains the button. But, if the macro
calls for information contained within a different sheet, the macro
fails. The strange part is that these macro run fine if there not
assigned to a command button. But once the same macro code is copied
into the private sub of a command button, it fails.

---
Message posted from http://www.ExcelForum.com/


--

Dave Peterson


Rob van Gelder[_4_]

Command Button
 
Could you please supply the code?

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"jongdg " wrote in message
...
This is probably a simple problem. There are certain macro's that I
want to assign a command button to. I have no problem if the macro
functions within the sheet that contains the button. But, if the macro
calls for information contained within a different sheet, the macro
fails. The strange part is that these macro run fine if there not
assigned to a command button. But once the same macro code is copied
into the private sub of a command button, it fails.


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 01:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com