VBA question

caritx

New Member
Joined
Dec 1, 2009
Messages
34
I want VBA to add my formula to a range of cells if they are empty.

(empty) <-- add formula
123
(empty) <-- add formula
abc

Thanks all!
 

Some videos you may like

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,955
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
You didn't say what your formula was, so I made a very simple one:

Code:
Sub test()
On Error Resume Next
Range("A1:A10").SpecialCells(xlCellTypeBlanks) = "=B1"
End Sub
 

jeffreybrown

Well-known Member
Joined
Jul 28, 2004
Messages
5,145
How about something like this for a sample...

Assumes A1 is a header row.

Code:
Sub Addformula()
    Dim LR As Long
    LR = Range("A" & Rows.Count).End(xlUp).Row
    Range("A2:A" & LR).SpecialCells(xlCellTypeBlanks).Formula = "=1+1"
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,108,960
Messages
5,525,906
Members
409,671
Latest member
nasseralateek

This Week's Hot Topics

Top