I have a VBA code that gives an address to an excel range that is active and selected. I am trying to get it as a string.
Sub getRange()
Dim atcSheet As Worksheet
Dim selRange As Range
Dim myRange As String
Set actSheet = ActiveSheet
Set selRange = Selection
MsgBox (selRange.Address)
myRange = selRange.Address(RowAbsolute, ColumnAbsolute)
MsgBox (myRange)
end sub
When running this (after having selected a few cells making a range), MsgBox returns the address, but i could not make it in a variable as a string.
If your intention is to get the absolute reference of the range into an string variable, this will do
myRange = selRange.Address
Address(True, True) is by default.
Use:
myRange = selRange.Address(True, True)
' for debug
MsgBox myRange
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With