George
Member
Hi all,
I've put together a macro to tell me the variable type used in a range. The code works fine and does its job well, but I'm wondering how Excel decides what data type numbers are represented as?
An example, a range containing only single digit numbers have been stored as Double - is this just how excel handles numbers, or is there something hidden somewhere that can tell me what data type it should be?
For the record (in case it helps), this is the code:
I've put together a macro to tell me the variable type used in a range. The code works fine and does its job well, but I'm wondering how Excel decides what data type numbers are represented as?
An example, a range containing only single digit numbers have been stored as Double - is this just how excel handles numbers, or is there something hidden somewhere that can tell me what data type it should be?
For the record (in case it helps), this is the code:
Code:
For ColCount = 1 To MaxCol 'cycle through all columns
MaxVar = 0 'restart MaxVar
For RowCount = 2 To MaxRow 'cycle through all rows
VarHolder = VarType(Cells(RowCount, ColCount))
If VarHolder = 10 Then '10 is error - this way we can easily find cells that have any possible problem data and can contact the client
Cells(RowCount, ColCount).Interior.ColorIndex = 3 'fill red
End If
If VarHolder > MaxVar Then 'keep MavVar as the highest level of datatype
MaxVar = VarHolder
End If
Next RowCount
Sheets("FieldLayout").Activate
Cells(ColCount + 3, 3).Value = VarTypeName(MaxVar) 'Module 6
Cells(ColCount + 3, 3).Borders.LineStyle = xlContinuous
Sheets("SourceData").Activate
Next ColCount