Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
I'm racking my brain; I thought there was a command called gosub that would
take you to a routine in your macro and then return to the gosub command. for example. sub test() if x=5 gosub calc_routine exit sub : calc_routine ' do something return end sub I've searched this site and MS and I'm stuck. Thanks |
#2
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
You don't need the gosub (anymore);
Sub test() test1 MsgBox "after test 1" End Sub Sub test1() MsgBox "test1" End Sub -- Kind regards, Niek Otten Microsoft MVP - Excel "El Bee" wrote in message ... | I'm racking my brain; I thought there was a command called gosub that would | take you to a routine in your macro and then return to the gosub command. | | for example. | | sub test() | if x=5 gosub calc_routine | | exit sub | | : calc_routine | ' do something | | return | end sub | | I've searched this site and MS and I'm stuck. | | Thanks |
#3
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Niek,
I removed the "gosub" and I still get an error. here's a portion of my code: While day_name < "XIT" .. .. ActiveCell.Offset(rowoffset:=0, columnoffset:=-1).Activate Tsd_title = ActiveCell.Value color_indx = 0 setcolors dayname .. .. .. Wend Exit Sub : dayname Select Case Day_Name Case "MON" Start_time_col = 2 Case "TUE" Start_time_col = 4 .. .. .. return : setcolors Select Case Tsd_title Case "Lead" color_indx = 10 Case "Super" color_indx = 5 Case "Tsd" color_indx = 35 Case "BI" color_indx = 45 Case "Night" color_indx = 47 Case "Facilities" color_indx = 9 Case "Prob Mgmt" color_indx = 3 End Select return "Niek Otten" wrote: You don't need the gosub (anymore); Sub test() test1 MsgBox "after test 1" End Sub Sub test1() MsgBox "test1" End Sub -- Kind regards, Niek Otten Microsoft MVP - Excel "El Bee" wrote in message ... | I'm racking my brain; I thought there was a command called gosub that would | take you to a routine in your macro and then return to the gosub command. | | for example. | | sub test() | if x=5 gosub calc_routine | | exit sub | | : calc_routine | ' do something | | return | end sub | | I've searched this site and MS and I'm stuck. | | Thanks |
#4
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
not
:dayname but Sub dayname ...... end sub see the example I gave -- Kind regards, Niek Otten Microsoft MVP - Excel "El Bee" wrote in message ... | Niek, | | I removed the "gosub" and I still get an error. | | here's a portion of my code: | | While day_name < "XIT" | . | . | ActiveCell.Offset(rowoffset:=0, columnoffset:=-1).Activate | Tsd_title = ActiveCell.Value | color_indx = 0 | | setcolors | | dayname | . | . | . | Wend | Exit Sub | | : dayname | Select Case Day_Name | Case "MON" | Start_time_col = 2 | Case "TUE" | Start_time_col = 4 | . | . | . | return | | : setcolors | | Select Case Tsd_title | Case "Lead" | color_indx = 10 | Case "Super" | color_indx = 5 | Case "Tsd" | color_indx = 35 | Case "BI" | color_indx = 45 | Case "Night" | color_indx = 47 | Case "Facilities" | color_indx = 9 | Case "Prob Mgmt" | color_indx = 3 | End Select | | return | | | | | "Niek Otten" wrote: | | You don't need the gosub (anymore); | | Sub test() | test1 | MsgBox "after test 1" | End Sub | | Sub test1() | MsgBox "test1" | End Sub | | -- | Kind regards, | | Niek Otten | Microsoft MVP - Excel | | "El Bee" wrote in message ... | | I'm racking my brain; I thought there was a command called gosub that would | | take you to a routine in your macro and then return to the gosub command. | | | | for example. | | | | sub test() | | if x=5 gosub calc_routine | | | | exit sub | | | | : calc_routine | | ' do something | | | | return | | end sub | | | | I've searched this site and MS and I'm stuck. | | | | Thanks | | | |
#5
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Niek,
That worked but now I'm having issues with some of my variables. How do I declare variables so they can be used between subs or functions. Sorry, my online help isn't working. El Bee "Niek Otten" wrote: not :dayname but Sub dayname ...... end sub see the example I gave -- Kind regards, Niek Otten Microsoft MVP - Excel "El Bee" wrote in message ... | Niek, | | I removed the "gosub" and I still get an error. | | here's a portion of my code: | | While day_name < "XIT" | . | . | ActiveCell.Offset(rowoffset:=0, columnoffset:=-1).Activate | Tsd_title = ActiveCell.Value | color_indx = 0 | | setcolors | | dayname | . | . | . | Wend | Exit Sub | | : dayname | Select Case Day_Name | Case "MON" | Start_time_col = 2 | Case "TUE" | Start_time_col = 4 | . | . | . | return | | : setcolors | | Select Case Tsd_title | Case "Lead" | color_indx = 10 | Case "Super" | color_indx = 5 | Case "Tsd" | color_indx = 35 | Case "BI" | color_indx = 45 | Case "Night" | color_indx = 47 | Case "Facilities" | color_indx = 9 | Case "Prob Mgmt" | color_indx = 3 | End Select | | return | | | | | "Niek Otten" wrote: | | You don't need the gosub (anymore); | | Sub test() | test1 | MsgBox "after test 1" | End Sub | | Sub test1() | MsgBox "test1" | End Sub | | -- | Kind regards, | | Niek Otten | Microsoft MVP - Excel | | "El Bee" wrote in message ... | | I'm racking my brain; I thought there was a command called gosub that would | | take you to a routine in your macro and then return to the gosub command. | | | | for example. | | | | sub test() | | if x=5 gosub calc_routine | | | | exit sub | | | | : calc_routine | | ' do something | | | | return | | end sub | | | | I've searched this site and MS and I'm stuck. | | | | Thanks | | | |
#6
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
If you need to; declare them outside your Subs, in the top of the Module.
Many pros wouldn't consider that good coding practice, though. If your application isn't too complex; don't bother. Otherwise, consider supplying arguments to subs rather than relying on global variables. -- Kind regards, Niek Otten Microsoft MVP - Excel "El Bee" wrote in message ... | Niek, | | That worked but now I'm having issues with some of my variables. | | How do I declare variables so they can be used between subs or functions. | | Sorry, my online help isn't working. | | El Bee | | "Niek Otten" wrote: | | not | | :dayname | | but | | Sub dayname | ...... | end sub | | see the example I gave | | -- | Kind regards, | | Niek Otten | Microsoft MVP - Excel | | "El Bee" wrote in message ... | | Niek, | | | | I removed the "gosub" and I still get an error. | | | | here's a portion of my code: | | | | While day_name < "XIT" | | . | | . | | ActiveCell.Offset(rowoffset:=0, columnoffset:=-1).Activate | | Tsd_title = ActiveCell.Value | | color_indx = 0 | | | | setcolors | | | | dayname | | . | | . | | . | | Wend | | Exit Sub | | | | : dayname | | Select Case Day_Name | | Case "MON" | | Start_time_col = 2 | | Case "TUE" | | Start_time_col = 4 | | . | | . | | . | | return | | | | : setcolors | | | | Select Case Tsd_title | | Case "Lead" | | color_indx = 10 | | Case "Super" | | color_indx = 5 | | Case "Tsd" | | color_indx = 35 | | Case "BI" | | color_indx = 45 | | Case "Night" | | color_indx = 47 | | Case "Facilities" | | color_indx = 9 | | Case "Prob Mgmt" | | color_indx = 3 | | End Select | | | | return | | | | | | | | | | "Niek Otten" wrote: | | | | You don't need the gosub (anymore); | | | | Sub test() | | test1 | | MsgBox "after test 1" | | End Sub | | | | Sub test1() | | MsgBox "test1" | | End Sub | | | | -- | | Kind regards, | | | | Niek Otten | | Microsoft MVP - Excel | | | | "El Bee" wrote in message ... | | | I'm racking my brain; I thought there was a command called gosub that would | | | take you to a routine in your macro and then return to the gosub command. | | | | | | for example. | | | | | | sub test() | | | if x=5 gosub calc_routine | | | | | | exit sub | | | | | | : calc_routine | | | ' do something | | | | | | return | | | end sub | | | | | | I've searched this site and MS and I'm stuck. | | | | | | Thanks | | | | | | | | | |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
goto (F5) question | Excel Discussion (Misc queries) | |||
GOTO with Macros | Excel Discussion (Misc queries) | |||
Goto code | Excel Discussion (Misc queries) | |||
Excel GOTO | Excel Discussion (Misc queries) | |||
If.....Then GoTo....... | Excel Discussion (Misc queries) |