MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

How to handle the Variant Data Type

  Asked By: Doan    Date: Jan 11    Category: MS Office    Views: 2079

I am not quite sure how to handle this data type selection. Any help
would be greatly appreciated.

Everything I have read has said to not use the Variant Data type. In
this situation it seems my only option.

1. Is it the correct choice for UpperRangeVal and LowerRangeVal?
2. If it is the correct choice should I declare it as Variant as
Any suggestions would be helpful. Thanks.

Sub MoveRange()

Const DRange As Integer = 35
Dim TopPart As Long
Dim TopPartA As Long
Dim GColumn As String
Dim GTop As String
Dim GTopA As String
Dim BodyB As String
Dim BodyA As String
Dim TimerRange As Long
Dim UpperRangeVal as Variant
Dim LowerRangeVal as Variant

TimerRange = Range("O10").Value 'Cell O10 = 30
MsgBox TypeName(TimerRange)
TopPart = DRange - TimerRange 'Range("O10").Value
MsgBox TypeName(TopPart)
TopPartA = TopPart - 1
MsgBox TypeName(TopPartA)
GColumn = "G"
MsgBox TypeName(GColumn)
GTop = GColumn & TopPart
MsgBox TypeName(GTop)
GTopA = GColumn & TopPartA
MsgBox TypeName(GTopA)
BodyB = GTop & ":J33"
MsgBox TypeName(BodyB)
BodyA = GTopA & ":J32"
MsgBox TypeName(BodyA)

UpperRangeVal = Range(BodyA).Value
LowerRangeVal = Range(BodyB).Value
UpperRangeVal = LowerRangeVal

'Range(BodyA).Value = Range(BodyB).Value
'MsgBox TypeName(Range(BodyA).Value)

End Sub()



1 Answer Found

Answer #1    Answered By: Beaudi Smith     Answered On: Jan 11

Variants can be very handy. No need to avoid them really, unless you
are concerned about speed or memory footprint. If your code works
with Variants, use them.

Didn't find what you were looking for? Find more on How to handle the Variant Data Type Or get search suggestion and latest updates.