Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default subroutine variable decleration issue

The following works:

sub subroutine(optional Byval strVariable as string = "Default String")

Can I do something similar to the following, which doesn't work?

sub subroutine2(optional byval rngVariable as range = range("A1:B2"))

Also are these routines public or private?

Thanks in advance,

Christmas May
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default subroutine variable decleration issue

Hi Chritmas,

Try:

Sub subroutine2(Optional rng As Range)

If rng Is Nothing Then Set rng = Range("A1:B2")


Also are these routines public or private?


That depends on the required scope.

Lokk in VBA help for 'Scope', 'Private' and 'Public'



---
Regards,
Norman



"Christmas May" wrote in message
...
The following works:

sub subroutine(optional Byval strVariable as string = "Default String")

Can I do something similar to the following, which doesn't work?

sub subroutine2(optional byval rngVariable as range = range("A1:B2"))

Also are these routines public or private?

Thanks in advance,

Christmas May



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
Call a subroutine using variable subroutine name dhstein Excel Discussion (Misc queries) 3 July 26th 09 08:28 PM
Multiple variable issue FadaSininho Excel Discussion (Misc queries) 1 August 17th 06 03:31 PM
Variable Decleration Christmas May[_2_] Excel Programming 2 June 30th 06 05:41 AM
Pass a Variable List Of Values To Subroutine or Function Dean Hinson[_3_] Excel Programming 2 January 28th 05 06:49 PM
system variable representing subroutine name? Bob Kilmer Excel Programming 0 July 9th 03 12:30 AM


All times are GMT +1. The time now is 07:36 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"