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


How do I call a macro, for instance I have 50 sheets on every sheet I
want to put a command button to go back to the main page (Sheet1). How
do I create one macro that goes Sheet1.activate and be able to call that
to run. I am new to the terminology of vba. Do I have to create a new
module or put it in this workbook?

Thanks for any help


--
jhahes
------------------------------------------------------------------------
jhahes's Profile: http://www.excelforum.com/member.php...o&userid=23596
View this thread: http://www.excelforum.com/showthread...hreadid=392594

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default calling a macro

Why not make a floating toolbar/commandbar with a single button that
activates sheet1.

Create the toolbar in the workbook_Open event and destroy it in the
workbook_BeforeClose event:

Here is an article about creating commandbars with code:
http://msdn.microsoft.com/library/techart/ofcmdbar.htm

Chip Pearson's page on Events:
http://www.cpearson.com/excel/events.htm

More on CommandBars:
http://support.microsoft.com/default...02&Product=xlw
How to customize menus and menu bars in Excel

http://support.microsoft.com/default...b;en-us;166755
File Title: Customizing Menu Bars, Menus, and Menu Items in Microsoft(R)
Excel 97
File Name: WE1183.EXE
File Size: 58041 bytes
File Date: 06/20/97
Keywords: kbfile kbappnote
Description: This Application Note can help you learn techniques for writing
Visual Basic(R) for Applications code to customize menus in Microsoft Excel
97. This Application Note contains code examples that you can use with the
following elements: menu bars, menus, menu items, submenus, and shortcut
menus.

--
Regards,
Tom Ogilvy


"jhahes" wrote in
message ...

How do I call a macro, for instance I have 50 sheets on every sheet I
want to put a command button to go back to the main page (Sheet1). How
do I create one macro that goes Sheet1.activate and be able to call that
to run. I am new to the terminology of vba. Do I have to create a new
module or put it in this workbook?

Thanks for any help


--
jhahes
------------------------------------------------------------------------
jhahes's Profile:

http://www.excelforum.com/member.php...o&userid=23596
View this thread: http://www.excelforum.com/showthread...hreadid=392594



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


Thanks Tom, I like that idea, didn't think of it. However the reason I
want each page to go back to the home page is that I would also put
this code in each command bar code.

Call Macro ("Sheet1".activate)
Sheet55.visible = xlhidden ' or whatever sheet i am on

Basically from the main page, a user can go to about 50 or so sheets
and look at the detail of some products, however when done looking I
would like for them to go back to the main page, but it leaves up the
page they just looked at the bottom, and pretty soon I have 25 or so
sheets open. I understand that I can hide all of them on Workbook_Open
or close.

Is there a better solution to this

Thanks for any help


--
jhahes
------------------------------------------------------------------------
jhahes's Profile: http://www.excelforum.com/member.php...o&userid=23596
View this thread: http://www.excelforum.com/showthread...hreadid=392594

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default calling a macro

You can incorporate this in the button to return to the main sheet

If ActiveSheet.Name "Sheet1" Then
ActiveSheet.Visible = xlVeryHidden
Sheets("Sheet1").Activate
End If


--
steveB

Remove "AYN" from email to respond
"jhahes" wrote in
message ...

Thanks Tom, I like that idea, didn't think of it. However the reason I
want each page to go back to the home page is that I would also put
this code in each command bar code.

Call Macro ("Sheet1".activate)
Sheet55.visible = xlhidden ' or whatever sheet i am on

Basically from the main page, a user can go to about 50 or so sheets
and look at the detail of some products, however when done looking I
would like for them to go back to the main page, but it leaves up the
page they just looked at the bottom, and pretty soon I have 25 or so
sheets open. I understand that I can hide all of them on Workbook_Open
or close.

Is there a better solution to this

Thanks for any help


--
jhahes
------------------------------------------------------------------------
jhahes's Profile:
http://www.excelforum.com/member.php...o&userid=23596
View this thread: http://www.excelforum.com/showthread...hreadid=392594



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default calling a macro

when the macro fires using the commandbar button, the sheet will still be
the activesheet

Sub Btn_Click()
if activesheet.name < sheet1.Name then
activesheet.visible = xlSheetHidden
End if
Sheet1.Activate
End sub

--
Regards,
Tom Ogilvy

"jhahes" wrote in
message ...

Thanks Tom, I like that idea, didn't think of it. However the reason I
want each page to go back to the home page is that I would also put
this code in each command bar code.

Call Macro ("Sheet1".activate)
Sheet55.visible = xlhidden ' or whatever sheet i am on

Basically from the main page, a user can go to about 50 or so sheets
and look at the detail of some products, however when done looking I
would like for them to go back to the main page, but it leaves up the
page they just looked at the bottom, and pretty soon I have 25 or so
sheets open. I understand that I can hide all of them on Workbook_Open
or close.

Is there a better solution to this

Thanks for any help


--
jhahes
------------------------------------------------------------------------
jhahes's Profile:

http://www.excelforum.com/member.php...o&userid=23596
View this thread: http://www.excelforum.com/showthread...hreadid=392594





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default calling a macro

? "AAAA" "Sheet1"
False

--
Regards,
Tom Ogilvy

"STEVE BELL" wrote in message
news:PS8Ie.32788$Tk6.17013@trnddc02...
You can incorporate this in the button to return to the main sheet

If ActiveSheet.Name "Sheet1" Then
ActiveSheet.Visible = xlVeryHidden
Sheets("Sheet1").Activate
End If


--
steveB

Remove "AYN" from email to respond
"jhahes" wrote in
message ...

Thanks Tom, I like that idea, didn't think of it. However the reason I
want each page to go back to the home page is that I would also put
this code in each command bar code.

Call Macro ("Sheet1".activate)
Sheet55.visible = xlhidden ' or whatever sheet i am on

Basically from the main page, a user can go to about 50 or so sheets
and look at the detail of some products, however when done looking I
would like for them to go back to the main page, but it leaves up the
page they just looked at the bottom, and pretty soon I have 25 or so
sheets open. I understand that I can hide all of them on Workbook_Open
or close.

Is there a better solution to this

Thanks for any help


--
jhahes
------------------------------------------------------------------------
jhahes's Profile:
http://www.excelforum.com/member.php...o&userid=23596
View this thread:

http://www.excelforum.com/showthread...hreadid=392594





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


Thank you both for the help. It works great! Really appreciate it, now
I don't have to install commandbuttons on 30 sheets.


--
jhahes
------------------------------------------------------------------------
jhahes's Profile: http://www.excelforum.com/member.php...o&userid=23596
View this thread: http://www.excelforum.com/showthread...hreadid=392594

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
Calling a variable macro Hari Prasadh[_2_] Excel Programming 2 July 30th 05 09:28 AM
Calling a macro from a key RWN Excel Programming 0 February 8th 05 05:19 AM
Calling Excel Macro From Vc++ via DDE hari Excel Programming 0 July 6th 04 12:50 PM
Calling a macro from an If statement Kathryn Excel Programming 6 April 5th 04 10:21 PM
Calling macro in add-in. Clark B Excel Programming 1 July 24th 03 11:05 PM


All times are GMT +1. The time now is 11:50 PM.

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"