Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Mike
 
Posts: n/a
Default How to assign a macro

I have a workbook with 30-40 different sheets, i have a command button on
each sheet that start a macro called Sub Producedwatersystem().

Is it possible that a form can appear at the same time as the workbook is
opened?
(a opening page).

Is it possible that the user can choose what sheet to be active and start
the macro from that form?
  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

Do you want the form to do anything, or just to flash up, a splash screen?
If the latter, see http://www.xldynamic.com/source/xld.xlFAQ0007.html

How do you want the selection to be invoiced.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mike" wrote in message
...
I have a workbook with 30-40 different sheets, i have a command button on
each sheet that start a macro called Sub Producedwatersystem().

Is it possible that a form can appear at the same time as the workbook is
opened?
(a opening page).

Is it possible that the user can choose what sheet to be active and start
the macro from that form?



  #3   Report Post  
Mike
 
Posts: n/a
Default

Hi Bob, thanks for helping me!

I dont want the form to do anything, But i want 2 command buttons on it, one
called Cancel and one called New input, both of them shall hide the form and
the last one should also start the macro assign to the worksheet

"Bob Phillips" wrote:

Do you want the form to do anything, or just to flash up, a splash screen?
If the latter, see http://www.xldynamic.com/source/xld.xlFAQ0007.html

How do you want the selection to be invoiced.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mike" wrote in message
...
I have a workbook with 30-40 different sheets, i have a command button on
each sheet that start a macro called Sub Producedwatersystem().

Is it possible that a form can appear at the same time as the workbook is
opened?
(a opening page).

Is it possible that the user can choose what sheet to be active and start
the macro from that form?




  #4   Report Post  
Bob Phillips
 
Posts: n/a
Default

I would add a listbox, and two buttons to the form. The listbox will list
all the sheets, the buttons will be a Cancel and a New button. The userform
code would then be


Private Sub CommandButto2_Click()
Unload Me
End Sub

Private Sub CommandButton1_Click()
If Me.ListBox1.ListIndex = -1 Then
MsgBox "Select a sheet"
Else
Worksheets(Me.ListBox1.Value).Activate
Call myMacro
Unload Me
End If
End Sub

Private Sub UserForm_Activate()
Dim sh As Worksheet

With ActiveWorkbook
For Each sh In .Worksheets
Me.ListBox1.AddItem sh.Name
Next sh
End With

End Sub



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mike" wrote in message
...
Hi Bob, thanks for helping me!

I dont want the form to do anything, But i want 2 command buttons on it,

one
called Cancel and one called New input, both of them shall hide the form

and
the last one should also start the macro assign to the worksheet

"Bob Phillips" wrote:

Do you want the form to do anything, or just to flash up, a splash

screen?
If the latter, see http://www.xldynamic.com/source/xld.xlFAQ0007.html

How do you want the selection to be invoiced.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mike" wrote in message
...
I have a workbook with 30-40 different sheets, i have a command button

on
each sheet that start a macro called Sub Producedwatersystem().

Is it possible that a form can appear at the same time as the workbook

is
opened?
(a opening page).

Is it possible that the user can choose what sheet to be active and

start
the macro from that form?






  #5   Report Post  
Michael
 
Posts: n/a
Default

Thanks Bob.

It works:-)

"Bob Phillips" wrote:

I would add a listbox, and two buttons to the form. The listbox will list
all the sheets, the buttons will be a Cancel and a New button. The userform
code would then be


Private Sub CommandButto2_Click()
Unload Me
End Sub

Private Sub CommandButton1_Click()
If Me.ListBox1.ListIndex = -1 Then
MsgBox "Select a sheet"
Else
Worksheets(Me.ListBox1.Value).Activate
Call myMacro
Unload Me
End If
End Sub

Private Sub UserForm_Activate()
Dim sh As Worksheet

With ActiveWorkbook
For Each sh In .Worksheets
Me.ListBox1.AddItem sh.Name
Next sh
End With

End Sub



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mike" wrote in message
...
Hi Bob, thanks for helping me!

I dont want the form to do anything, But i want 2 command buttons on it,

one
called Cancel and one called New input, both of them shall hide the form

and
the last one should also start the macro assign to the worksheet

"Bob Phillips" wrote:

Do you want the form to do anything, or just to flash up, a splash

screen?
If the latter, see http://www.xldynamic.com/source/xld.xlFAQ0007.html

How do you want the selection to be invoiced.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mike" wrote in message
...
I have a workbook with 30-40 different sheets, i have a command button

on
each sheet that start a macro called Sub Producedwatersystem().

Is it possible that a form can appear at the same time as the workbook

is
opened?
(a opening page).

Is it possible that the user can choose what sheet to be active and

start
the macro from that form?








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
Assign Macro SUE M Excel Discussion (Misc queries) 1 September 22nd 07 09:00 PM
Assign to macro missing Paul Excel Discussion (Misc queries) 2 January 22nd 05 09:55 AM
How to assign a macro to a commnd button Mickey Blue Eyes Excel Discussion (Misc queries) 2 January 4th 05 02:15 PM
Assign Macro to button in Excel doesnt work Any ideas? Mike@Becketts Excel Discussion (Misc queries) 2 December 20th 04 02:47 PM
assign a macro to a control button ewan72 Excel Discussion (Misc queries) 1 December 3rd 04 02:04 PM


All times are GMT +1. The time now is 12:32 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"