Dynamic Range $B$1:$B$2 changes to $B$2

MarcDS

New Member
Joined
Aug 3, 2022
Messages
3
Office Version
  1. 2016
Platform
  1. Windows
I define a dynamic named range with
Worksheets("Cleaned").Names.Add Name:="Date", RefersToR1C1:="=Cleaned!R2C2:INDEX(Cleaned!C2, COUNTA(Cleaned!C2))"

Before execution of the following loop a watch Worksheets("Cleaned").Range("Date").Address shows that the range is $B$1:$B$2

For I = 2 To NRows
Worksheets("Cleaned").Range("Date").Cells(I).NumberFormat = "yyyy-mm-dd"
Worksheets("Cleaned").Range("Date").Cells(I) = Worksheets("Cleaned").Range("Date_and_Time").Cells(I - 1)
... other instructions which do not influence this problem. The changes described below occur after the execution of the statement above.
Next I

After the first iteration the correct cell of Date_and_Time is copied to the correct cell in Date (Cell A2 copied to B2). The watch shows range $B$2
After the second iteration the correct cell of Date_and_Time is copied to a cell under the targeted cell in Date (Cell A2 copied to B3). The watch shows range $B$2:$B$3
After the third iteration thec orrect cell of Date_and_Time is copied to a cell under the targeted cell in Date (Cell A3 copied to B4.) The watch shows range $B$2:$B$4
Next iteration continue to do the same: copying the correct cell to a cell under the targeted cell

Why is the range changed to $B$2 after the first iteration. I would expect it to be $B$2:$B$3. What error dit I make?
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Forum statistics

Threads
1,223,723
Messages
6,174,123
Members
452,546
Latest member
Rafafa

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