Fill cell if empty
Posted on 2011-03-05
I am new to Excel coding and was trying to figure a way to fill in cells.
Using Excel 2007
Example: I have 2 ranges set.
Range 1 = cells B2, C2 and D2
Range 2 = cells D6, E6 and F6
All cells are blank.
If I enter anything in either of the cells in Range 1 then all the cells in Range 2 are filled in and as long as anything stays in Range 1 nothing can be entered in Range 2.
I then need an error message to pop up stating that you can only enter information for one range.
I tried this as a start to fill in if not blank and that is why I am asking for help.
Private Sub Worksheet_Blank(ByVal Target As Range)
Dim r As Range
If Target.Address <> "$B$2:$D$2" Then Exit Sub
Set r = Range("D6:F6")
If Target <> " " Then
.Interior.ColorIndex = 3