Probably this is an easy question, but I can't find out how to do it.
How can I let VBA check if a cell is empty? I want to check 6 cells if they are empty, and if they're not empty, fill in another cell a formula.
Please can somebody help me?
Probably this is an easy question, but I can't find out how to do it.
How can I let VBA check if a cell is empty? I want to check 6 cells if they are empty, and if they're not empty, fill in another cell a formula.
Please can somebody help me?
the IsEmtpy function will do this, e.g.If IsEmpty(ActiveCell) Then MsgBox "Active cell is empty"
K :-)
Can I also put a formatting in?
Because other cells are also calculated and I want to put that color on white when the first column is empty.
Please help again Killian
You can do anything you like!
IsEmpty tests a Range object so you can use any of the Range methods or properties. For example:
Sub test() Dim myRange As Range 'the range of cell you want to test Dim c As Range 'the cell you test each time Set myRange = ActiveSheet.Range("A1:A20") For Each c In myRange ' for each cell in the range If IsEmpty(c) Then 'if the cell is empty c.Value = "I was empty" 'change the value c.Interior.Color = vbRed 'change the color 'etc, etc... End If Next c End Sub
K :-)