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
| 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
| >
| > | 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
| > | >
| > | > | 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
| > | >
| > | >
| > | >
| >
| >
| >