R
ryguy7272
This is a trick one! I am trying to figure out how to identify blanks in a
range, and then get Excel to give me the ‘Address’ of each blank cell. I got
some great help at this DG last week and my code (below) works, but I am
wondering if I can modify it slightly. Currently, any blanks that are
identified are listed in column AX, and the list starts in AX3 and goes down
one and over zero (rngToPaste.Offset(1, 0)). I am curious to know if I can
get the rngToPaste.Offset to be equal to the row that the blanks are on. For
instance, if I have a blank cell in E3, I want this cell address to be
displayed in AX3, and if I have a blank in F3, I want I want this cell
address to be displayed in AY3, and if I have a blank in G3, I want this cell
address to be displayed in AZ3. Then, if the next blank is in F5, I want
this address to be displayed in AX5. Essentially, I want the cell Addresses
to correspond to the rows than the blanks are on, instead if shifting down
one cell in Column AX each time a blank is found. I assume this is possible.
I am guessing it would be something like: Offset(0, 1) and then Offset(1,
0), but I don't know how to modify the code to do what I want to do. Does
anyone know if this is possible?
My current code is listed below:
Sub FindBlanks()
Dim rngMyRange As Range
Dim rngBlanks As Range
Dim rngToPaste As Range
Dim rng As Range
On Error Resume Next
Set rngMyRange = Union(Range("E3:W330"), Range("Y3:AE330"))
Set rngBlanks = rngMyRange.SpecialCells(xlCellTypeBlanks)
On Error GoTo 0
Set rngToPaste = rngBlanks
If Not rngBlanks Is Nothing Then
Set rngToPaste = Sheets("15.1 Detail - Madeup").Range("AX3")
For Each rng In rngBlanks
rngToPaste.Value = rng.Address
Set rngToPaste = rngToPaste.Offset(1, 0)
Next rng
End If
End Sub
Cordially,
Ryan---
range, and then get Excel to give me the ‘Address’ of each blank cell. I got
some great help at this DG last week and my code (below) works, but I am
wondering if I can modify it slightly. Currently, any blanks that are
identified are listed in column AX, and the list starts in AX3 and goes down
one and over zero (rngToPaste.Offset(1, 0)). I am curious to know if I can
get the rngToPaste.Offset to be equal to the row that the blanks are on. For
instance, if I have a blank cell in E3, I want this cell address to be
displayed in AX3, and if I have a blank in F3, I want I want this cell
address to be displayed in AY3, and if I have a blank in G3, I want this cell
address to be displayed in AZ3. Then, if the next blank is in F5, I want
this address to be displayed in AX5. Essentially, I want the cell Addresses
to correspond to the rows than the blanks are on, instead if shifting down
one cell in Column AX each time a blank is found. I assume this is possible.
I am guessing it would be something like: Offset(0, 1) and then Offset(1,
0), but I don't know how to modify the code to do what I want to do. Does
anyone know if this is possible?
My current code is listed below:
Sub FindBlanks()
Dim rngMyRange As Range
Dim rngBlanks As Range
Dim rngToPaste As Range
Dim rng As Range
On Error Resume Next
Set rngMyRange = Union(Range("E3:W330"), Range("Y3:AE330"))
Set rngBlanks = rngMyRange.SpecialCells(xlCellTypeBlanks)
On Error GoTo 0
Set rngToPaste = rngBlanks
If Not rngBlanks Is Nothing Then
Set rngToPaste = Sheets("15.1 Detail - Madeup").Range("AX3")
For Each rng In rngBlanks
rngToPaste.Value = rng.Address
Set rngToPaste = rngToPaste.Offset(1, 0)
Next rng
End If
End Sub
Cordially,
Ryan---