psi
New Member
- Joined
- Sep 16, 2012
- Messages
- 5
I got a macro connected to a button that select empty cells within a range and fill them with the value above. The code looks like this:
If you press the button twice you will get run-time error 1004 becuase Excel can't find any empty cells.
I want a function that counts blank cells before running the macro. If there are no blanks I don't want to execute the macro. That is to avoid run-time error 1004.
Can you guys help me out?
Code:
Range("A1:A10").SpecialCells(xlCellTypeConstants, 23).Select
Selection.Resize(, 4).Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.FormulaR1C1 = "=R[-1]C"
Range("A1:A10").SpecialCells(xlCellTypeConstants, 23).Select
Selection.Resize(, 4).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues
If you press the button twice you will get run-time error 1004 becuase Excel can't find any empty cells.
I want a function that counts blank cells before running the macro. If there are no blanks I don't want to execute the macro. That is to avoid run-time error 1004.
Can you guys help me out?