Trying to create a dynamic named range

gshock

New Member
Joined
Jan 26, 2013
Messages
33
Office Version
  1. 365
Platform
  1. Windows
I'm trying to create a named range that can be resized based on the number of rows, but I'm getting an invalid use of property error, and I don't understand why. I'm trying to follow the VBA code in this post, and I don't know what I'm doing wrong.



1701273918260.png
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
You can't have Range("Location").Rows.Count on a line like that because it doesn't mean anything. It's just a number which you could display (MsgBox), use with another object or method.

For example, in the linked thread, Range("InputClaims").Columns.Count is used as the 2nd argument to the Resize method - the number of columns to resize Range("AC22") by.
 
Upvote 0
John_w, thanks for your help. Sorry for the late reply.

When
VBA Code:
Range("AC22")
is used in this way, it serves as a starting point? Correct? Is he determining how many columns to resize by using this:
VBA Code:
Resize(Application.WorksheetFunction.CountA(Range("data_date_range")) + 1
 
Upvote 0
Posting the complete statement from the linked thread for clarity:

VBA Code:
Set sourceRange = Range("AC22").Resize(Application.WorksheetFunction.CountA(Range("data_date_range")) + 1, _
                                Range("InputClaims").Columns.Count
is used in this way, it serves as a starting point?

Yes, Range("AC22") is the starting point for resizing the range, in this case a single cell.

Is he determining how many columns to resize by using this:

No, that part specifies the number of rows to resize by. Resize takes 2 arguments: the number of rows to resize by and the number of columns to resize by. See Range.Resize property (Excel)
 
Upvote 0
Solution

Forum statistics

Threads
1,215,349
Messages
6,124,427
Members
449,158
Latest member
burk0007

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