ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,226
- Office Version
- 2007
- Platform
- Windows
Hi,
Code in use as supplide.
I complete the userform but when i press the command button to send the values to the worksheet i now see End If Without Block If.
Code in use as supplide.
I complete the userform but when i press the command button to send the values to the worksheet i now see End If Without Block If.
VBA Code:
Private Sub CommandButton1_Click()
Dim i As Integer
Dim X As Long
Dim ControlsArr(1 To 8) As Variant
For i = 1 To 8
If i > 2 Then
With Me.Controls("ComboBox" & i)
If .ListIndex = -1 Then
MsgBox "YOU MUST COMPLETE ALL FIELDS", vbCritical, "MC LIST TRANSFER"
TextBox1.SetFocus
Exit Sub
Else
ControlsArr(i) = .Value
End If
End With
Else
ControlsArr(i) = Me.Controls("TextBox" & i).Value
End If
Next i
Application.ScreenUpdating = False
With ThisWorkbook.Worksheets("MC LIST")
.Range("A8").EntireRow.Insert Shift:=xlDown
.Range("A8:I8").Borders.Weight = xlThin
.Cells(8, 1).Resize(, UBound(ControlsArr)).Value = ControlsArr
End With
Range("B8").Select
Range("A8").Select
ActiveWorkbook.Save
Application.ScreenUpdating = True
MsgBox "Database Has Been Updated", vbInformation, "SUCCESSFUL MESSAGE"
With ThisWorkbook.Worksheets("MC LIST")
If .AutoFilterMode Then .AutoFilterMode = False
X = .Cells(.Rows.Count, 1).End(xlUp).Row
.Range("A7:I" & X).Sort Key1:=Range("A8"), Order1:=xlAscending, Header:=xlGuess
.Range("A8").Select
End With
End If
Unload McListForm
End Sub