How can I copy the returned range address that’s displayed in a MessageBox to a cell on the same sheet.
Having established what the used range is with the code below, I want to put that returned range address into a cell.
eg-: so W10 will = the rng.Address
Have tried numerous bits found on line, to no avail.
Have tried; copy to ClipBoard using Ctrl-C, then use Ctrl-V to paste in cell, but its pasting ALL the Msg box properties but I ONLY want the Range Address.
Having established what the used range is with the code below, I want to put that returned range address into a cell.
eg-: so W10 will = the rng.Address
Have tried numerous bits found on line, to no avail.
Have tried; copy to ClipBoard using Ctrl-C, then use Ctrl-V to paste in cell, but its pasting ALL the Msg box properties but I ONLY want the Range Address.
VBA Code:
Sub MeUsedRangetest()
Dim lastRow As Long, firstrow As Long
Dim rng As Range
Dim sht As Worksheet
Dim sMsg As String
Set sht = ThisWorkbook.ActiveSheet
firstrow = sht.Range("s:s").Find(what:="CF rules", LookIn:=xlValues, LookAt:=xlWhole).Row
lastRow = sht.Range("T:T").Find(what:="Cash Paid", LookIn:=xlValues, LookAt:=xlWhole).Row
Set rng = sht.Range("T" & firstrow & ":T" & lastRow)
MsgBox "Range is " & rng.Address
End Sub