ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   userforms / worksheets (https://www.excelbanter.com/excel-programming/324869-userforms-worksheets.html)

Gixxer_J_97[_2_]

userforms / worksheets
 
i am writing a help system for my vba/excel project
the help is launched from a button on each worksheet in the workbook
each button calls the same help system

the help is built with a userform and a multi-page

how do i detect which worksheet the help was launched from in order to set
the mult-page to the correct page?

ie if the user is on 'sheet 2' and they click the help button, the help will
come up and display 'page 2'

tia

J

Toppers

userforms / worksheets
 
ActiveSheet.name will give you the name of worksheet. I assume the HELP
button on the worksheet is attached to a macro which invokes the Help
Userform so you will have name available to you.

e.g. hlpSheet=Activeworksheet.Name

HTH

"Gixxer_J_97" wrote:

i am writing a help system for my vba/excel project
the help is launched from a button on each worksheet in the workbook
each button calls the same help system

the help is built with a userform and a multi-page

how do i detect which worksheet the help was launched from in order to set
the mult-page to the correct page?

ie if the user is on 'sheet 2' and they click the help button, the help will
come up and display 'page 2'

tia

J


Glenn Ray[_3_]

userforms / worksheets
 
Test for ActiveSheet.Name, like so:

Select Case ActiveSheet.Name
Case "Sheet1"
'calls up help for Sheet1
Case "Sheet2"
'calls up help for Sheet2
..
..
..

End Select

"Gixxer_J_97" wrote:

i am writing a help system for my vba/excel project
the help is launched from a button on each worksheet in the workbook
each button calls the same help system

the help is built with a userform and a multi-page

how do i detect which worksheet the help was launched from in order to set
the mult-page to the correct page?

ie if the user is on 'sheet 2' and they click the help button, the help will
come up and display 'page 2'

tia

J


Harald Staff

userforms / worksheets
 
Hi J

That depends. Is Sheet 2 the second sheet from the left ? If so

Select Case ActiveSheet.Index
Case 2
MsgBox "Yo"
Case Else
'...

Ensure that users can't move, delete, insert sheets if so.
If Sheet 2 is the sheet name then

Select Case ActiveSheet.Name
Case "Sheet 2"
MsgBox "Yo"
Case Else
'...

Ensure that users can't rename the sheets if so.
Then you have code names (=name in the project explorer, like Sheet2). But
maybe there's an even better identifier or way to do this ?

HTH. Best wishes Harald

"Gixxer_J_97" skrev i melding
...
i am writing a help system for my vba/excel project
the help is launched from a button on each worksheet in the workbook
each button calls the same help system

the help is built with a userform and a multi-page

how do i detect which worksheet the help was launched from in order to set
the mult-page to the correct page?

ie if the user is on 'sheet 2' and they click the help button, the help

will
come up and display 'page 2'

tia

J




Gixxer_J_97[_2_]

userforms / worksheets
 
thanks to all! some great ideas to work with!
i'ld like to keep it as dynamic as possible so if in the future i need to
add another sheet (or move sheets around) i won't have to re-code everything.

J

"Harald Staff" wrote:

Hi J

That depends. Is Sheet 2 the second sheet from the left ? If so

Select Case ActiveSheet.Index
Case 2
MsgBox "Yo"
Case Else
'...

Ensure that users can't move, delete, insert sheets if so.
If Sheet 2 is the sheet name then

Select Case ActiveSheet.Name
Case "Sheet 2"
MsgBox "Yo"
Case Else
'...

Ensure that users can't rename the sheets if so.
Then you have code names (=name in the project explorer, like Sheet2). But
maybe there's an even better identifier or way to do this ?

HTH. Best wishes Harald

"Gixxer_J_97" skrev i melding
...
i am writing a help system for my vba/excel project
the help is launched from a button on each worksheet in the workbook
each button calls the same help system

the help is built with a userform and a multi-page

how do i detect which worksheet the help was launched from in order to set
the mult-page to the correct page?

ie if the user is on 'sheet 2' and they click the help button, the help

will
come up and display 'page 2'

tia

J





Julian[_2_]

userforms / worksheets
 
Hi,
You could try this code.

Sub myHelp()
mysheet = ActiveSheet.Name
Select Case mysheet
Case Is = "Sheet1"
UserForm1.MultiPage1.Value = 0
UserForm1.Show
Case Is = "Sheet2"
UserForm1.MultiPage1.Value = 1
UserForm1.Show
End Select
End Sub

Regards,
Julian
http://www.angelfire.com/biz7/julian...ans_macros.htm

i am writing a help system for my vba/excel project
the help is launched from a button on each worksheet in the workbook
each button calls the same help system

the help is built with a userform and a multi-page

how do i detect which worksheet the help was launched from in order to set
the mult-page to the correct page?

ie if the user is on 'sheet 2' and they click the help button, the help will
come up and display 'page 2'

tia

J



All times are GMT +1. The time now is 05:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com