LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Variable problem

Can someone please tell me what I'm doing wrong?

If I use a variable vRngName and set it to NamedRng1 (the name of a
named range), this procedure runs fine.

Sub test()
Dim vRngName As String
vRngName = "NamedRng1"
Range(vRngName).Select
End Sub


Now if I split this into 2 procedures and put Public vRngName As
String at the top of the module and run the following, I get an error
on line 1 of the second procedure "Method 'Range' of object' _global'
failed"

Sub test()
Dim vRngName As String
vRngName = "NamedRng1"
Call test2
End Sub

Sub test2()
Range(vRngName).Select 'error is here
End Sub

Why does using 2 procedures cause this to fail?
Thanks for the help
 
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
SaveAS w/ a variable name problem Jeffp Excel Programming 2 June 8th 04 12:51 PM
Problem with a defined variable ric Excel Programming 2 April 26th 04 08:42 PM
Object variable problem ExcelMonkey[_13_] Excel Programming 4 January 23rd 04 08:39 PM
vba variable problem joao Excel Programming 3 December 15th 03 04:31 PM
Problem trying to us a range variable as an array variable TBA[_2_] Excel Programming 4 September 27th 03 02:56 PM


All times are GMT +1. The time now is 12:23 AM.

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

About Us

"It's about Microsoft Excel"