View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Frank Kabel Frank Kabel is offline
external usenet poster
 
Posts: 3,885
Default set variable once

Hi Bob
thanks for the correction. Should not code directly in OE :-)

--
Regards
Frank Kabel
Frankfurt, Germany

"Bob Phillips" schrieb im
Newsbeitrag ...
public user as range

sub temp1()
set user = sheets("1").range("a1")
msgbox user.value
end sub

You don't use Dim and Public, and you cannot use Set method outside

of a
procedure.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"mike allen" wrote in message
...
"expected: identifier" comes up on "public" in first line. the

entire
first line is red, probably pre-warning me of this error. i copied

exactly
as you have. i must be doing something else wrong. thanks, mike

allen

"Frank Kabel" wrote in message
...
Hi
try:
dim public user as range
set user = sheets("1").range("a1")

sub temp1()
msgbox user.value
end sub


--
Regards
Frank Kabel
Frankfurt, Germany

"mike allen" schrieb im Newsbeitrag
...
is it possible to set a variable just once and have many subs

use it?
example:

user = sheets("1").range("a1") 'i would like to have this set

only
once at
top of module sheet

sub temp1()
msgbox user 'i would like for this and many other subs to know

what
'user'
is
end sub

i know i can define 'user' in a sub, then use sub temp1(user),

but i
would
rather not since there will be so many subs w/ 'user' needed.
thanks, mike
allen