Home > Blockchain >  Range Variable storing string variable
Range Variable storing string variable

Time:11-22

So I run into a problem where I Dim A as range, but when I set A = to cells(1,1) and Cell(1,1) happen to be fill in with a text let say "BB" then A = "BB" instead of range("A1"). Can someone explain to me wat going on.

I Haven't tried anything as I don't know where to start I have been trying to work around it but I cant anymore

CodePudding user response:

A is a range - but the default property of Range is value.

Depending on how you output A - the value-property is used.

Sub test()
Dim A As Range
Set A = ActiveSheet.Cells(1, 1)      'cell content = BB

Debug.Print A.Address, A.Value, A

End Sub

Output in the immediate window:

$A$1 BB BB

CodePudding user response:

Then how do I set overwrite the A (range Variable) with a new range. As base of the explanation above if A = cells(1,1) and cells(1,1).value is BB, then u set A = cells(1,2) while cells(1,2).value is CC. That would not overwrite the the Value of cells(1,1) with the Value of cells(1,2) but wont change the store range variable of A?

  • Related