Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default command button()_click


hi,
sorry if these questions have been asked many times.

i am working through various books on using vba within excel and in
each of the books i cant find any answers. Each of the books suggests
that you create a command button so that if you click on it it will run
your code. Is it possible to:

1. run the code by just pressing enter on your keyboard-ie if the value
in cell(1,1) is a certain thing ,just by pressing enter can it trigger
off the rest of the code instead of having to click on the command
button
2. is it possible to have the command button on the top tool bar and if
so how can i do this.


many thanks in advance


--
iamkeen
------------------------------------------------------------------------
iamkeen's Profile: http://www.excelforum.com/member.php...o&userid=17752
View this thread: http://www.excelforum.com/showthread...hreadid=384155

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default command button()_click


Good morning Iamkeen

1. The way to do this is run an event procedure, where the code is
asking, if this cell = x then ... To do this you need to enclose your
code in this (as opposed to the usual Sub x() / End Sub constuct):

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As
Range)
End Sub

and put it into the ThisWorkbook section of the VBE (see here for more
details http://www.cpearson.com/excel/events.htm)

2. You can't put a command button in a toolbar - only on a worksheet.
You can add another icon to a toolbar. Tools Customize and under
Toolbars selext Add. Once you have a new toolbar choose an icon under
the commands tab and drag it to your toolbar. Once it's there right
click and a drop down menu will appear with plenty of options. Among
the options will be to rename the button, edit the button (if you come
over all artistic!) or to assign a macro.

HTH

DominicB


--
dominicb
------------------------------------------------------------------------
dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932
View this thread: http://www.excelforum.com/showthread...hreadid=384155

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default command button()_click


hi dominicb

thankyou for the speady reply.much appreciated. i will be trying them
out later.
thanks once again


--
iamkeen
------------------------------------------------------------------------
iamkeen's Profile: http://www.excelforum.com/member.php...o&userid=17752
View this thread: http://www.excelforum.com/showthread...hreadid=384155

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default command button()_click


Hi Iamkeen

You're welcome. I appreciate the feedback.

DominicB


--
dominicb
------------------------------------------------------------------------
dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932
View this thread: http://www.excelforum.com/showthread...hreadid=384155

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default command button()_click


hi dominicb,

just checked it and it works better than i thought.

thanks again


--
iamkeen
------------------------------------------------------------------------
iamkeen's Profile: http://www.excelforum.com/member.php...o&userid=17752
View this thread: http://www.excelforum.com/showthread...hreadid=384155



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default command button()_click


"dominicb" wrote in
message ...
1. The way to do this is run an event procedure, where the code is
asking, if this cell = x then ... To do this you need to enclose your
code in this (as opposed to the usual Sub x() / End Sub constuct):

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As
Range)
End Sub

and put it into the ThisWorkbook section of the VBE (see here for more
details http://www.cpearson.com/excel/events.htm)


If you use this method, you must ensure that you use a commandbuttonb from
the control toolbox. And it won't work just by using the Enter key.

You could also use a command button from the forms toolbar, but in this case
you just assign a macro that runs on a click. Again, it won't run from an
enter,



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
command button add another command Wanna Learn Excel Discussion (Misc queries) 5 December 7th 08 11:42 PM
Can anyone help with _click() events? Peter[_48_] Excel Programming 4 November 7th 04 01:46 PM
help with vba and command button RichardO[_5_] Excel Programming 5 May 27th 04 07:37 PM
Command Button vs Control Button RGibson Excel Programming 1 October 14th 03 02:24 AM
Command Button vs Form Button T K Excel Programming 4 August 26th 03 07:26 PM


All times are GMT +1. The time now is 09:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"