How to know the real range of a dynamic range

MarcDS

New Member
Joined
Aug 3, 2022
Messages
3
Office Version
  1. 2016
Platform
  1. Windows
I use statements as

Worksheets("Cleaned").Names.Add Name:="Date_and_Time", RefersToR1C1:="=Cleaned!R2C1:INDEX(Cleaned!C1, COUNTA(Cleaned!C1))"

Worksheets("Cleaned").Names.Add Name:="Date", RefersToR1C1:="=Cleaned!R2C2:INDEX(Cleaned!C2, COUNTA(Cleaned!C2))"

Worksheets("Cleaned").Names.Add Name:="Month", RefersToR1C1:="=Cleaned!R2C3:INDEX(Cleaned!C3, COUNTA(Cleaned!C3))"

in VBA to define dynamic ranges.



Since I find strange (for me unexplicable) things during the execution of my VBA code I would like to see what is actual range of these ranges.
Example Date_and_Time is A1:a1021, Date is B2:b1021 etc.



Is there a way to do that?
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Welcome to the Board!

Something like this would work:
VBA Code:
    MsgBox Range("Date_and_Time").Address

By the way, I would recommend NOT using names of built-in Excel functions like "Date" and "Time" as the name of your named ranges.
 
Upvote 0
Solution
Welcome to the Board!

Something like this would work:
VBA Code:
    MsgBox Range("Date_and_Time").Address

By the way, I would recommend NOT using names of built-in Excel functions like "Date" and "Time" as the name of your named ranges.
Thanks a lot. I used Worksheets("Cleaned").Range("Date").Address etc as watches. This allowed me to understand why my code behaved so erratically.
 
Upvote 0

Forum statistics

Threads
1,224,808
Messages
6,181,073
Members
453,020
Latest member
mattg2448

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top