View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Variables initiation

Hi,

In a macro the variables are 'generally' initialised at the top of the code:-

Sub MyMacro()
Dim x as Long
Dim MyRange as range

etc.

By default when initialised they ere empty and you then have to assign a value

Sub MyMacro()
Dim x as Long
Dim MyRange as range
x=999
set MyRange=range("A1:A1000")

Mike

"Alberto Ast" wrote:

Thanks Ryan..

Somehow I can not see this post when I list all those I have had some
activities but Mike H have forward me the link and I was able to see the
post... any way... pearson link showed me how to declare variables but how do
I gave them an initial value different than its default value?

"Ryan H" wrote:

I guess it would help if I gave you the link, sorry.

http://www.cpearson.com/excel/DeclaringVariables.aspx
--
Cheers,
Ryan


"Ryan H" wrote:

You declare variables many ways. Check this link out by Chip Pearson. It
helped me when I was learning.

Hope this helps! If so, let me know, click "YES" below.
--
Cheers,
Ryan


"Alberto Ast" wrote:

I need to initiate some variables...

to initiate the variables within a form I use

Private Sub UserForm_Initialize()
......
End Sub

How do I do it within a module?