If column A contains project number, check that columns B-N contain text

dan_adelais

New Member
Joined
May 15, 2017
Messages
12
Hi All,

I'm building an intake form. The individual enters a project number in column A (eg. PRJ001, PRJ002) and columns B through N need to contain data relating to that project. I'm trying to build a macro that checks column A for any project number (anything beginning with PRJ) and then checks columns B through N to see if they contain text. If not, a message box asking them to fill in those fields appears. The message box doesn't need to specify which fields need to be filled in, but it would be nice if it could.

VBA is not my strong suit. Any help is greatly appreciated.
 

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.
since you are potentially making 14 entries into the row, a worksheet event code does not seem practical. But the code below could be run when the user thinks they have finished and check to see if they missed anything.

VBA Code:
Sub t()
Dim c As Range
    With ActiveSheet
        For Each c In .Range("A2", .Cells(Rows.Count, 1).End(xlUp))
            If Left(UCase(c.Value), 3) = "PRJ" Then
                If Application.CountA(c.Offset(, 1).Resize(, 13)) <> 13 Then
                    MsgBox "You Must fill all cells for Row " & c.Row & " Columns B:N"
                End If
            End If
        Next
    End With
End Sub
 
Upvote 0
Solution
since you are potentially making 14 entries into the row, a worksheet event code does not seem practical. But the code below could be run when the user thinks they have finished and check to see if they missed anything.

VBA Code:
Sub t()
Dim c As Range
    With ActiveSheet
        For Each c In .Range("A2", .Cells(Rows.Count, 1).End(xlUp))
            If Left(UCase(c.Value), 3) = "PRJ" Then
                If Application.CountA(c.Offset(, 1).Resize(, 13)) <> 13 Then
                    MsgBox "You Must fill all cells for Row " & c.Row & " Columns B:N"
                End If
            End If
        Next
    End With
End Sub
Fantastic. Running this on close attempt works like a charm. Thank you so much!
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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