ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel macro to name ranges always start in A and end in U (https://www.excelbanter.com/excel-programming/345894-excel-macro-name-ranges-always-start-end-u.html)

Ocicat

Excel macro to name ranges always start in A and end in U
 
I need a macro that will name ranges that aren't always the same number of
rows, but always start in column A and end in column U.

Bob Phillips[_6_]

Excel macro to name ranges always start in A and end in U
 
Give this a try, and let us know

Set rng = Range(Range("A1"),Cells(Rows.Count,"A").End(xlUp)) .Resize(,21)
rng.Name = "range_name"

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Ocicat" wrote in message
...
I need a macro that will name ranges that aren't always the same number of
rows, but always start in column A and end in column U.




chijanzen

Excel macro to name ranges always start in A and end in U
 
Ocicat:
Other means

ActiveWorkbook.Names.Add Name:="range_name", RefersTo:= _
"=OFFSET($A$1,,,COUNTA($A$1:$A$65536),21)"


--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Ocicat" wrote:

I need a macro that will name ranges that aren't always the same number of
rows, but always start in column A and end in column U.



All times are GMT +1. The time now is 11:45 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com