I have a loop I am trying to use to find all blank cells in a Column and enter a formula in those blank cells. The loop works but never stops b/c there are blanks in the Column after the data set. I will post the code that I normally use and then what I have tried to fix it without success. Thanks for any help!!!
Started with:
I have tried this:
And this changing columns to Range:
Started with:
Code:
Do
If Not Columns("P:P").Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
True, SearchFormat:=False) Is Nothing Then
Columns("P:P").Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
True, SearchFormat:=False).Activate
ActiveCell.Select
ActiveCell.FormulaR1C1 = "=RC[1]"
ActiveCell.Copy
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
ActiveCell.Offset(0, 1).ClearContents
Else
Exit Do
End If
Loop
I have tried this:
Code:
LastRow = Range("A65536").End(xlUp).Row
Do
If Not Columns("P:P" & LastRow).Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, LookAt
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
True, SearchFormat:=False) Is Nothing Then
Columns("P:P & LastRow").Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
True, SearchFormat:=False).Activate
ActiveCell.Select
ActiveCell.FormulaR1C1 = "=RC[1]"
ActiveCell.Copy
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
ActiveCell.Offset(0, 1).ClearContents
Else
Exit Do
End If
Loop
And this changing columns to Range:
Code:
LastRow = Range("A65536").End(xlUp).Row
Do
If Not Range("P:P" & LastRow).Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, LookAt
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
True, SearchFormat:=False) Is Nothing Then
Range("P:P & LastRow").Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
True, SearchFormat:=False).Activate
ActiveCell.Select
ActiveCell.FormulaR1C1 = "=RC[1]"
ActiveCell.Copy
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
ActiveCell.Offset(0, 1).ClearContents
Else
Exit Do
End If
Loop