New to VBA and using a lot of the Macro Recorder. Tried my best to speed up this code, but it still takes a long time. Hoping someone has some advice for me? This code is unloading a userform. I appreciate the help in advance!
VBA Code:
Private Sub SubmitButton_Click()
Application.ScreenUpdating = False
Application.CutCopyMode = False
If ComboBox1.value = "" Then
MsgBox "Enter Manager Name", , "Error"
Exit Sub
End If
If ComboBox4.value = "" Then
MsgBox "Enter Employee Name", , "Error"
Exit Sub
End If
If TextBox3.value = "" Then
MsgBox "Enter Date", , "Error"
Exit Sub
End If
If ComboBox3.value = "" Then
MsgBox "Enter Details About Topics Discussed", , "Error"
Exit Sub
End If
Sheets("Entries").Visible = True
Sheets("Entries").Range("A2").End(xlDown).Select
Selection.Offset(1, 0).value = ComboBox1.value
Selection.Offset(1, 1).value = ComboBox4.value
Selection.Offset(1, 2).value = TextBox3.value
Selection.Offset(1, 3).value = ComboBox3.value
Selection.Offset(1, 4).Formula = "=DATE(YEAR(C" & ActiveCell.Offset(1, 0).Row & "),FLOOR(MONTH(C" & ActiveCell.Offset(1, 0).Row & ")+2,3)+1,0)"
Selection.Offset(1, 5).Formula = "=VLOOKUP($B" & ActiveCell.Offset(1, 0).Row & ",EmpData!$A:$E,5,True)"
Selection.Offset(1, 4) = Selection.Offset(1, 4).value
Selection.Offset(1, 5) = Selection.Offset(1, 5).value
Range(Range("A2"), Selection.End(xlToRight).End(xlDown)).Select
ActiveWorkbook.Worksheets("Entries").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Entries").Sort.SortFields.Add2 Key:=Range("C2:C1000" _
), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Entries").Sort
.SetRange Range("A2:F1000")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Sheets("Home").Select
Sheets("Entries").Visible = False
Unload Take30
ThisWorkbook.Save
MsgBox "Entry Complete!"
End Sub
Last edited by a moderator: