Command button code(SC)

  • Thread starter Thread starter Ram
  • Start date Start date
R

Ram

Hi,

I have 4 madatory cells in my Excel sheet, and I have to design it in
such a way that if and only if these 4 cells are filled and on
clicking next button it should take us to the next page"Worksheet
name : nxt_pg". If any on the cell is Blank a msg box should appear
asking to Provide Details and on clicking OK it should activate the
cell that is left blank. All the 4 cells are named (R_nm, E-ml, Date,
Cntry).

Thanks for your help in advance

SC
 
Hi Ram,

Try something like:

'=============>>
Private Sub CommandButton1_Click()
Dim Rng As Range
Dim Rng2 As Range

Set Rng = Me.Range("R_nm,Eml,Date,Cntry") '<<=== CHANGE

On Error Resume Next
Set Rng2 = Rng.SpecialCells(xlCellTypeBlanks)
On Error GoTo 0

If Not Rng2 Is Nothing Then
MsgBox Prompt:="All of the cells " _
& Rng.Address(False, False) _
& " should be completed.", _
Buttons:=vbInformation, _
Title:="Missing Data"
Rng2.Cells(1).Select
Exit Sub
End If

Me.Next.Select

End Sub
'<<=============
 
opps. wrong thread
sorry
FSt1







- Show quoted text -

Thanks a lot this works.. But instead of cell numbers I want to
declare specific names to be displayed in the message box as this code
returns a msg box that says "All of the cells H13, H14, H15, H16
should be completed". Is it Possible.
 
Thanks a lot this works.. But instead of cell numbers I want to
declare specific names to be displayed in the message box as this code
returns a msg box that says "All of the cells H13, H14, H15, H16
should be completed". Is it Possible.- Hide quoted text -

- Show quoted text -

I have fixed the issue of getting names instead of cell address.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top