View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
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