Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Add a button to a macro


At the moment I use a shortcut-key for a macro. Now what I would like is
a person to click a button which activates the macro instead of them
using the shortcut-key.


Code:
--------------------
Sub SearchAndOpen()
'
' SearchAndOpen Macro
' Macro recorded 7/07/2006 by Tom Fack
'
' Keyboard Shortcut: Ctrl+r
'

Dim s1 As String, bk As Workbook, bk1 As Workbook
s1 = "C:\Documents and Settings\" & _
"fackt0\Desktop\Excel Probleem\Shipments\"

Set bk = ActiveWorkbook
If Dir(s1 & Range("J5").Text & ".xls") < "" Then
Set bk1 = Workbooks.Open(s1 & Range("J5").Text & ".xls")
bk.Activate
Else
MsgBox "workbook not found"
End If

End Sub
--------------------


This is one of the examples which uses a shortcut-key at the moment.


--
TomBP
------------------------------------------------------------------------
TomBP's Profile: http://www.excelforum.com/member.php...o&userid=36112
View this thread: http://www.excelforum.com/showthread...hreadid=559844

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,073
Default Add a button to a macro

Hi Tom,

I like to use a button from the Forms toolbar.

Go View|Toolbars|Forms,then click on the little button icon on the
Forms Toolbar then click on your worksheet. The "Assign Macro" dialog
that appears should have your macro's name in the list of macros. You
can either double click its name or single click it then click the OK
button. After doing that your macro should run when you click the
button. To make any changes to the button's appearance just right click
it first.

I prefer this button to the Command Button from the Control Toolbar
because it works on PCs and Macs.

Ken Johnson

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Add a button to a macro


Thx Ken. I thought it would be a whole lot of code but its as easy as
getting up in the morning for work ;)


--
TomBP
------------------------------------------------------------------------
TomBP's Profile: http://www.excelforum.com/member.php...o&userid=36112
View this thread: http://www.excelforum.com/showthread...hreadid=559844

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Add a button to a macro


Thx Ken. I thought it would be a whole lot of code but its as easy as
getting up in the morning for work ;)


--
TomBP
------------------------------------------------------------------------
TomBP's Profile: http://www.excelforum.com/member.php...o&userid=36112
View this thread: http://www.excelforum.com/showthread...hreadid=559844

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Add a button to a macro


Thx Ken. I thought it would be a whole lot of code but its as easy as
getting up in the morning for work ;)


--
TomBP
------------------------------------------------------------------------
TomBP's Profile: http://www.excelforum.com/member.php...o&userid=36112
View this thread: http://www.excelforum.com/showthread...hreadid=559844



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Add a button to a macro


Thx Ken. I thought it would be a whole lot of code but its as easy as
getting up in the morning for work ;)


--
TomBP
------------------------------------------------------------------------
TomBP's Profile: http://www.excelforum.com/member.php...o&userid=36112
View this thread: http://www.excelforum.com/showthread...hreadid=559844

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,073
Default Add a button to a macro


Hi Tom,

At the moment I wouldn't know about that, I'm currently on holiday:-)

Thanks for the feedback.

Ken Johnson

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
Use Macro To Change Which Macro Assigned To Command Button CVinje Excel Discussion (Misc queries) 0 May 25th 10 09:55 PM
Creating a macro which presses a button containing a recorded macro petros89[_3_] Excel Programming 3 October 5th 05 02:49 PM
Can't select macro button after other button is pressed C. Campbell Excel Programming 1 November 30th 04 07:46 PM
Pause macro, add form button to sheet, continue macro when button clicked! Flystar[_15_] Excel Programming 1 May 26th 04 09:45 AM
How to end macro on inital active worksheet containing macro button that was clicked Silverhawk1 Excel Programming 2 May 14th 04 03:58 PM


All times are GMT +1. The time now is 03:22 AM.

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

About Us

"It's about Microsoft Excel"