James - try this, which will also stop the flickering:
Private Sub Cmdbutton_add_Click()
Dim ws As Worksheet
Application.ScreenUpdating = False
Set ws = Worksheets("EmailDatabase")
'check for a first name
If Trim(Me.FirstNameTextBox.Value) = "" Then
Me.FirstNameTextBox.SetFocus
MsgBox "Please enter a first name"
Exit Sub
End If
'check for a email address
If Trim(Me.EmailAddressTextBox.Value) = "" Then
Me.EmailAddressTextBox.SetFocus
MsgBox "Please enter a email address"
Exit Sub
End If
'copy the data to the database
'use protect and unprotect lines,
' with your password
' if worksheet is protected
With ws
' .Unprotect Password:="password"
.Cells(2, 1).Resize(, 6).Insert shift:=xlDown
With .Cells(2, 1).Resize(, 6)
.Interior.Color = xlNone
.Font.Bold = False
.HorizontalAlignment = xlLeft
End With
.Cells(2, 1).Value = Me.FirstNameTextBox.Value
.Cells(2, 2).Value = Me.LastNameTextBox.Value
.Cells(2, 3).Value = Me.CompanyNameTextBox.Value
.Cells(2, 4).Value = Me.EmailAddressTextBox.Value
.Cells(2, 5).Value = Me.TelephoneNumberTextBox.Value
' .Protect Password:="password"
End With
'clear the data
Me.FirstNameTextBox.Value = ""
Me.LastNameTextBox.Value = ""
Me.CompanyNameTextBox.Value = ""
Me.EmailAddressTextBox.Value = ""
Me.TelephoneNumberTextBox.Value = ""
If StagOptionButton.Value = True Then
Cells(2, 6).Value = "Stag"
End If
If HenOptionButton.Value = True Then
Cells(2, 6).Value = "Hen"
End If
If CorporateOptionButton.Value = True Then
Cells(2, 6).Value = "Corporate"
End If
If TeamBuildingOptionButton.Value = True Then
Cells(2, 6).Value = "Team Building"
End If
If ActivityWeekendOptionButton.Value = True Then
Cells(2, 6).Value = "Activity Weekend"
End If
If LocalGroupOptionButton.Value = True Then
Cells(2, 6).Value = "Local Group"
End If
If LocalCompanyOptionButton.Value = True Then
Cells(2, 6).Value = "Local Company"
End If
If OtherOptionButton.Value = True Then
Cells(2, 6).Value = "Other"
End If
Application.ScreenUpdating = True
End Sub
Bookmarks