I had a hard time selecting a specific headline. Nevertheless I hope someone is able to help me out.
I know that I can reference a Range via a String like this:
Dim Str as String
Str = "A1:A10"
ThisWorkbook.Sheets("Table1").Range(Str).Select
[...]
ThisWorkbook.Sheets("Table2").Range(Str).Select
[...]
But is it also possible to address a specific Range by putting the whole statement between the two dots like 'Range("A1:A10")' into a variable?
It would be handy since I often copy and paste code and sometimes I need to reference 'Rows(1:5)', sometimes 'Columns(A:E)', or a specific 'Range("A1:A10")'. Then I need to go through the whole code and replace these parts.
It would be great to just define this part within a variable in the beginning and use it throughout the script. Something like
Dim Rfrc As String
Rfrc = Rows("1:5")
or Rfrc = Columns("A:E")
or Rfrc = Range("A1:A10")
ThisWorkbook.Sheets("Table1").Rfrc.Select
[...]
ThisWorkbook.Sheets("Table2").Rfrc.Select
[...]
This is really my first question here and I hope you could help me out. So far I was always able to find answers to all my questions here, but this time I couldn't.