ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,251
- Office Version
- 2007
- Platform
- Windows
Evening.
I am using the code as supplied below.
I enter the data in my userform.
I then transfer the data to my worksheet & see the userform close.
I see the data entered at row 5
I NOW SEE THE CURSOE GOING ROUND & ROUND
I then see the success message.
I then click ok.
So the lag that i see must be the sorting process.
Please advise if you see an issue of why this is happening or maybe advice how to condense the code if need be.
Thanks
I am using the code as supplied below.
I enter the data in my userform.
I then transfer the data to my worksheet & see the userform close.
I see the data entered at row 5
I NOW SEE THE CURSOE GOING ROUND & ROUND
I then see the success message.
I then click ok.
So the lag that i see must be the sorting process.
Please advise if you see an issue of why this is happening or maybe advice how to condense the code if need be.
Thanks
Rich (BB code):
Private Sub TransferButton_Click()
Dim i As Long
Dim x As Long
Dim ctrl As Control
Dim lastrow As Long
Cancel = 0
If TextBox1.Text = "" Then
Cancel = 1
MsgBox "CUSTOMER'S NAME FIELD IS EMPTY", vbCritical, "RANGER FIELD EMPTY MESSAGE"
TextBox1.SetFocus
ElseIf TextBox2.Text = "" Then
Cancel = 1
MsgBox "VIN FIELD IS NOT ENTERED", vbCritical, "RANGER FIELD EMPTY MESSAGE"
TextBox2.SetFocus
ElseIf ComboBox5.Text = "" Then
Cancel = 1
MsgBox "YEAR IS NOT ENTERED", vbCritical, "RANGER FIELD EMPTY MESSAGE"
ComboBox5.SetFocus
ElseIf ComboBox1.Text = "" Then
Cancel = 1
MsgBox "MY PART NUMBER IS NOT ENTERED", vbCritical, "RANGER FIELD EMPTY MESSAGE"
ComboBox1.SetFocus
ElseIf ComboBox2.Text = "" Then
Cancel = 1
MsgBox "FORD PART NUMBER IS NOT ENTERED", vbCritical, "RANGER FIELD EMPTY MESSAGE"
ComboBox2.SetFocus
ElseIf ComboBox3.Text = "" Then
Cancel = 1
MsgBox "ITEM IS NOT ENTERED", vbCritical, "RANGER FIELD EMPTY MESSAGE"
ComboBox3.SetFocus
ElseIf ComboBox4.Text = "" Then
Cancel = 1
MsgBox "TYPE IS NOT ENTERED", vbCritical, "RANGER FIELD EMPTY MESSAGE"
ComboBox4.SetFocus
End If
If Cancel = 1 Then
Exit Sub
End If
Rows("5:5").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Range("B5:H5").Borders.LineStyle = xlContinuous
Range("B5:H5").Borders.Weight = xlThin
Range("B5:H5").Interior.ColorIndex = 6
Range("C5:H5").HorizontalAlignment = xlCenter
Range("B5").HorizontalAlignment = xlLeft
Sheets("RANGER").Range("B5").Select
Cancel = 0
If Cancel = 1 Then
Exit Sub
End If
With ThisWorkbook.Worksheets("RANGER")
.Range("B5").Value = TextBox1.Text
.Range("D5").Value = TextBox2.Text
.Range("C5").Value = ComboBox5.Text
.Range("E5").Value = ComboBox1.Text
.Range("F5").Value = ComboBox2.Text
.Range("G5").Value = ComboBox3.Text
.Range("H5").Value = ComboBox4.Text
End With
With Sheets("RANGER")
If .AutoFilterMode Then .AutoFilterMode = False
x = .Cells(.Rows.Count, 5).End(xlUp).Row
.Range("A4:H" & x).Sort Key1:=Range("B5"), Order1:=xlAscending, Header:=xlGuess
End With
Unload RangerForm
ActiveWorkbook.Save
MsgBox "DATABASE HAS BEEN UPDATED", vbInformation, "SUCCESSFUL MESSAGE"
Application.ScreenUpdating = True
Range("B6").Select
Range("B5").Select
End Sub