tourless
Board Regular
- Joined
- Feb 8, 2007
- Messages
- 144
- Office Version
- 365
- Platform
- Windows
Hi Folks.
I have a bunch of sheets and depending on the data they may contain one or more items that are subtotaled. If there are multiple items the code below works fine but sometimes there is only one item and it fails. How can I account for instances where there is only one item? What happens is rRange2 gets set to nothing and skips 'Fill Blank Cells Column A.
I have a bunch of sheets and depending on the data they may contain one or more items that are subtotaled. If there are multiple items the code below works fine but sometimes there is only one item and it fails. How can I account for instances where there is only one item? What happens is rRange2 gets set to nothing and skips 'Fill Blank Cells Column A.
VBA Code:
Sub FillBlanksA_MTD()
Dim rRange1 As Range, rRange2 As Range
Dim iReply As Integer
'Set Error Handling for Blank Cells
Set rRange1 = Range(Selection.Cells(1, 1), Cells(65536, Selection.Column).End(xlUp))
On Error Resume Next
Set rRange2 = rRange1
On Error GoTo 0
If rRange2 Is Nothing Then
FillBlanksC_MTD
End If
'Fill Blank Cells Column A
rRange2.FormulaR1C1 = "=R[-1]C"
rRange1 = rRange1.Value
Cells(Rows.Count, "A").End(xlUp).Copy Cells(Rows.Count, "A").End(xlUp).Offset(1)
FillBlanksC_MTD
End Sub