VBA data types

xcel

New member
Joined
May 13, 2018
Messages
8
Reaction score
0
Points
0
Excel Version(s)
2016
Hey Friends,

I am new to VBA and was learning some basics data types. I have seen some videos where they declare

Dim A as range
Dim ws as worksheet

I know these are variable declaration but the data types i know are integer, bytes, long, double etc. So, what are these range and worksheet means. what type of declarations are these. Any input is appreciated

Thanks
 
.
Dim A as Range = The variable A represent a range on the sheet. Ex: Range("A1:K1")

So ... in a macro you might have something like :

Sub YourMacro()
Dim A As Range

Set A = Sheet1.Range("A1:K1")

' more code here that will affect A

End Sub



Dim ws as worksheet = The variable ws represents a worksheet.

So ... in a macro you might have something like :

Sub YourMacro()
Dim ws as Worksheet

Set ws = Sheets("Sheet1")

'more code here that will affect ws

End Sub
 
Thank Logit,

That make more sense now
 
Back
Top