Solved Excel - Macro to check cell contents complete

Microsoft Excel 2003 (full product)
February 9, 2012 at 04:07:40
Specs: Windows XP
I want to run a macro in Excel 2003 that will check whether a cell has been completed, and if so, proceed to another worksheet. If the cell has not been completed, I want it to bring up a message to explain what needs to be completed.

I'm still very new to VBA! So any help would be appreciated.

Thanks


See More: Excel - Macro to check cell contents complete

Report •


#1
February 9, 2012 at 12:10:21
As a generic example, this will check A1:A10 and each time it finds an empty cell, it will present a message box.

I know that this won't fit your needs, but you didn't provide very much detail. It's just an example of how it could be done.

Sub CheckCells()
 For rw = 1 To 10
  If Cells(rw, "A") = "" Then
   MsgBox "Cell " & Cells(rw, "A").Address & " is incomplete"
  End If
 Next
End Sub

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.


Report •

#2
February 15, 2012 at 11:55:44
Hi DerbyDad03

Thanks for your response.

When someone clicks a "proceed to next worksheet" button, I need the attached macro to check that a cell (say B1) has the word "yes" entered into it. If so, I need the macro to bring up another worksheet. If the cell (B1) hasn't been completed, I need a message box to pop up stating "You must complete cell (B1) before proceeding".

Any further help would be much appreciated.

Thanks.

Nadia


Report •

#3
February 15, 2012 at 12:29:50
✔ Best Answer
Try assigning the following code to the button:

Sub CheckB1()
'Check to see if B1 contains Yes
  If UCase(Range("B1")) <> UCase("Yes") Then
'If B1 doesn't contain yes, present the message
    MsgBox "Cell B1 Must Contain Yes"
'If B1 does contain Yes, activate another worksheet
'(insert worksheet name between quotes)
  Else: Sheets("another worksheet").Activate
  End If
End Sub

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.


Report •

Related Solutions

#4
February 20, 2012 at 05:32:20
Thank you so much DerbyDad03.

This has worked a treat!!!!

:-)


Report •

Ask Question