Can I create Named Ranges for "Blank Range One, Two & Three" using the Offset function so that it allows for new blank cells (highlighted yellow)
to be added or deleted between the existing named ranges, "Input_Data" , "Exclusive" , "New_Way" , "Old_Way", that will not get messed up
as they do at the moment by using "Refers to".
The # of blank rows between will NEVER be less than one but could be several.
Another option would be to utilise (in some way) the various FirstRow & LastRow that I have already established below ?
My apologise, yet again for some reason xl2bb has not provided the Named Ranges.
[/CODE]
to be added or deleted between the existing named ranges, "Input_Data" , "Exclusive" , "New_Way" , "Old_Way", that will not get messed up
as they do at the moment by using "Refers to".
The # of blank rows between will NEVER be less than one but could be several.
Another option would be to utilise (in some way) the various FirstRow & LastRow that I have already established below ?
My apologise, yet again for some reason xl2bb has not provided the Named Ranges.
CountBlanksBetweenRanges.xlsm | |||||
---|---|---|---|---|---|
A | B | C | |||
1 | |||||
2 | |||||
3 | "INPUT DATA" | < this is NameRange "Input_Data" | |||
4 | |||||
5 | Has data | ||||
6 | Has data | ||||
7 | Has data | ||||
8 | Has data | ||||
9 | < will be "BlankRangeOne" | ||||
10 | "EXCLUSIVE" | < this is NamedRange "EXCLUSIVE" | |||
11 | |||||
12 | Has formula | ||||
13 | Has formula | ||||
14 | < will be "BlankRangeTwo" | ||||
15 | |||||
16 | "NEW WAY" | < this is NameRange "NEW_WAY" | |||
17 | |||||
18 | |||||
19 | Has formula | ||||
20 | Has formula | ||||
21 | < will be "BlankRangeThree" | ||||
22 | |||||
23 | |||||
24 | "OLD WAY" | < this is NameRange "OLD WAY" | |||
25 | |||||
26 | |||||
27 | Has formula | ||||
28 | Has formula | ||||
Sheet1 |
VBA Code:
Option Explicit
Sub BlanksBetween()
Dim FirstRowIP As Long 'of Input_Data
Dim LastRowIP As Long 'of Input_Data
Dim FirstRowEX As Long 'of EXCLUSIVE
Dim LastRowEX As Long 'of EXCLUSIVE
Dim FirstRowNW As Long 'of NEW_WAY
Dim LastRowNW As Long 'of NEW_WAY
Dim FirstRowOW As Long 'of OLD_WAY
Dim LastRowOW As Long 'of OLD_WAY
Dim BlankRangeOne As Range
Dim BlankRangeTwo As Range
Dim BlankRangeThree As Range
FirstRowIP = Range("Input_Data").Cells.Find("*", SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row - 5
LastRowIP = Range("Input_Data").Cells.Find("*", SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
FirstRowEX = Range("Exclusive").Cells.Find("*", SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row - 3
LastRowEX = Range("Exclusive").Cells.Find("*", SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
FirstRowNW = Range("New_Way").Cells.Find("*", SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row - 4
LastRowNW = Range("New_Way").Cells.Find("*", SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
FirstRowOW = Range("Old_Way").Cells.Find("*", SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row - 4
LastRowOW = Range("Old_Way").Cells.Find("*", SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
'---------------------------------------
' Next line does return RunTime Error 1004, but something along that line to establish "BlankRangeOne"
BlankRangeOne = Range("A" & LastRowIP + 1 & "A" & FirstRowEX)
BlankRangeTwo = ??
BlankRangeThree = ??
End Sub