PDA

View Full Version : Solved: insert letter into blank cells



inajica
01-16-2011, 10:05 AM
I have a range c2:g16. Some are filled with numbers and the others are just blank cells. I would like a macro that will insert a letter A into the blank cells. Thank you.

Paul_Hossler
01-16-2011, 10:56 AM
You can use the macro recorder as a starting point (Macro1)

BUT you always need to clean up the recorded code (Macro1_Editied) to make it more efficient and maintainable


Sub Macro1()
Range("C2:G16").Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.FormulaR1C1 = "A"
Range("C2").Select
End Sub

Sub Macro1_edited()
On Error Resume Next
ActiveSheet.Range("C2:G16").SpecialCells(xlCellTypeBlanks).Value = "A"
On Error GoTo 0
End Sub


Paul

inajica
01-16-2011, 11:26 AM
That worked. Thanks.