ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,832
- Office Version
- 2007
- Platform
- Windows
Morning,
I am using the code shown below but need some advice please.
There is nothing to stop me pressing the CommandButton and saving blank info to the worksheet cells.
It would be nice that each ComboBox MUST have a value in it BEFORE it can be sent to the worksheet,maybe in the way of an msg box & advising you which ComboBox it is refering to.
Example for the ComboBox with chip selection,
"Please select a chip"
Thanks
I am using the code shown below but need some advice please.
There is nothing to stop me pressing the CommandButton and saving blank info to the worksheet cells.
It would be nice that each ComboBox MUST have a value in it BEFORE it can be sent to the worksheet,maybe in the way of an msg box & advising you which ComboBox it is refering to.
Example for the ComboBox with chip selection,
"Please select a chip"
Thanks
Code:
Private Sub CommandButton1_Click()
With Sheets("CHIPS")
Sheets("CHIPS").Range("D4").Select
ActiveCell.EntireRow.Insert Shift:=xlDown
Sheets("CHIPS").Range("D4:I4").Select
Selection.Borders.Weight = xlThin
Sheets("CHIPS").Range("D4").Select
.Range("D4").Value = Me.ComboBox1.Text
.Range("E4").Value = Me.ComboBox2.Text
.Range("F4").Value = Me.ComboBox3.Text
.Range("G4").Value = Me.TextBox1.Text
.Range("H4").Value = Me.TextBox2.Text
.Range("I4").Value = Me.ComboBox4.Text
End With
Dim ctrl As MSForms.Control
For Each ctrl In Me.Controls
Select Case True
Case TypeOf ctrl Is MSForms.TextBox
ctrl.Value = ""
Case TypeOf ctrl Is MSForms.combobox
ctrl.Value = ""
End Select
Next ctrl
MsgBox "Database Has Been Updated", vbInformation, "SUCCESSFUL MESSAGE"
ComboBox1.SetFocus
End Sub