Help with macro!!

  • Thread starter Thread starter nrage21
  • Start date Start date
N

nrage21

I have the following situation...

...............E................F...............G
1
2
so on
7..........Jose.......1 Lake Ave......Tx.........[Commandbutton]

Code:
Private Sub Commandbutton_Click()
If Range("E7") <> "" And Range("F7") <> "" And Range("G7) <> "" Then
ActiveWorkbook.Save
Else
MsgBox "Unable to book! Complete ALL Fields"
End If
End Sub

Obviously the If and Then statement doesn't work (wrong syntax)... can
someone provide me with a solution?? I want the user to complete these
fields and then click the commandbutton that will check if all ranges
are completed and save the workbook.

TIA
- Larry -
VBA Amateur
 
Is it just the missing quotes after the G7?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Try this one

Sub test()
If Application.WorksheetFunction.CountA(Range("E7:G7")) < _
Range("E7:G7").Cells.Count Then
MsgBox "Unable to book! Complete ALL Fields"
Else
ActiveWorkbook.Save
End If
End Sub
 
Or your macro

And Range("G7)
must be
And Range("G7")

Private Sub Commandbutton_Click()
If Range("E7") <> "" And Range("F7") <> "" And Range("G7") <> "" Then
ActiveWorkbook.Save
Else
MsgBox "Unable to book! Complete ALL Fields"
End If
End Sub
 
How do I protect this cells when an user clicks the commandbutton?


Private Sub Commandbutton_Click()
If Range("E7") <> "" And Range("F7") <> "" And Range("G7) "" Then
ActiveWorkbook.Save
Else
MsgBox "Unable to book! Complete ALL Fields"
End If
End Sub


I Tried... Range("E7").Locked = True.... but I'm not getting th
expected outcome. Any ideas?

- Larry -
VBA Amateu
 
Nevermind! I Got it

ActiveSheet.Unprotect
Range("E7").Locked = True
ActiveSheet.Protect DrawingObjects:=True, Contents:=True
Scenarios:=True

- Larry -
VBA Amateu
 
Back
Top