ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Range naming cells with blank cells through coding (https://www.excelbanter.com/excel-discussion-misc-queries/181497-range-naming-cells-blank-cells-through-coding.html)

Naveen J V

Range naming cells with blank cells through coding
 
Hi,

Through macro, how do I name a range which consists of blank cells in
between. The range will be derived dynamically, where only the starting cell
is known. For example, Range starts frm A5, and end cell should be selected
dynamically based on the data. In between the dynamic range there may be some
blank cells. How to I code?

Thanks in advance


Gary''s Student

Range naming cells with blank cells through coding
 
The following will create a Named range of the empty cells below A5 until a
non-empty cell is found:

Sub servient()
Set a5 = Range("A5")
s = "=Sheet1!$A$6:$A$" & a5.End(xlDown).Row - 1
ActiveWorkbook.Names.Add Name:="bigji", RefersTo:=s
End Sub

--
Gary''s Student - gsnu200776


"Naveen J V" wrote:

Hi,

Through macro, how do I name a range which consists of blank cells in
between. The range will be derived dynamically, where only the starting cell
is known. For example, Range starts frm A5, and end cell should be selected
dynamically based on the data. In between the dynamic range there may be some
blank cells. How to I code?

Thanks in advance



All times are GMT +1. The time now is 08:28 PM.

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