Change cell range so its able to find the first empty cell in 4 columns

danbates

Active Member
Joined
Oct 8, 2017
Messages
377
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I would like to change the following code so instead of the code looking for B7,C7,D7,F7 cells I would like it to look for the first empty cell in the same columns.

My form is locked so only the active row can be selected and the entries will always be on the same row. So the entries cannot be staggered.

Here is my code:

Code:
Sub MyCellCheck()

    Dim cell As Range
    Dim str As String
    Dim bIsEmpty As Boolean


For Each cell In Range("B7,C7,D7,F7")
    If IsEmpty(cell) = True Then
            str = str & Cells(6, cell.Column).Value & vbCrLf
            cell.Interior.Color = RGB(255, 0, 0)
        bIsEmpty = True
    End If
Next cell
    
If bIsEmpty = True Then


MsgBox "Please complete the following highlighted cells:  " & vbNewLine & vbNewLine & str


For Each cell In Range("B7,C7,D7,F7")
            cell.Interior.Color = RGB(255, 255, 255)
Next cell
    End If
End Sub

Any help would be much appreciated.

Thanks

Dan
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,223,893
Messages
6,175,242
Members
452,623
Latest member
russelllowellpercy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top