![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Posts: 1,290
|
When I open my workbook,I become two sheets named: Test and Test1
In the tab sheet Test there is a macro that I can run via the toolbar. Is there a possibility that when I pressed the tab Test, this macro will autimatickly run? Thanks for any solution. |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
Put your macro in the following procedure:
Private Sub Worksheet_Activate() 'insert your code here End Sub Right click on the worksheet tab, and go to view code. Paste this code in the big blank area.
__________________
Kind regards, Al Chara |
|
|
|
|
|
#3 | |
|
Board Regular
Join Date: Mar 2002
Posts: 1,290
|
Quote:
Any other solution? Many thanks |
|
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
What is the code that you are trying to use?
|
|
|
|
|
|
#5 | |
|
Board Regular
Join Date: Mar 2002
Posts: 1,290
|
Quote:
Sub Worksheet_Activate() Dim a, b, c, d, e, f As Byte Dim LoadCol As Integer, x Dim nums As Integer, maxdiff As Integer, Counter As Long Dim filename1 As String nums = CInt(InputBox("Maximum numbers?") maxdiff = CInt(InputBox("Maximum difference ?) When I pressed on the tab Test,from my sheet I must receive these two inputboxes. Thanks for help. |
|
|
|
|
|
|
#6 | ||
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
Quote:
Make sure that you have events enabled: Application.EnableEvents = True
__________________
Kind regards, Al Chara |
||
|
|
|
|
|
#7 | |||
|
Board Regular
Join Date: Mar 2002
Posts: 1,290
|
Quote:
work when I select the tab Test I have to go to the macro himself to start. |
|||
|
|
|
|
|
#8 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
Are you getting an error?
Without seeing more of your code, all I can say is make sure you have the code in the correct location. Right click on the Test worksheet tab and select "View Code". Make sure that you have your code in the following event: Private Sub Worksheet_Activate() 'Insert code here End Sub Make sure everything in the above code is spelled correctly and that you didn't accidently delete the "End Sub" or something silly like that.
__________________
Kind regards, Al Chara |
|
|
|
|
|
#9 | |
|
Board Regular
Join Date: Mar 2002
Posts: 1,290
|
Quote:
Its strange to me. |
|
|
|
|
|
|
#10 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
When you run it from the toolbar, where is the macro located?
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|