I've created a user form for people to enter data into. All is working well in the workbook, except this form is slowing things down. It takes WAY too long to process the data that is entered (and thus allocated).
Any suggestions on how to speed this up?
Private Sub cboDept1_Change()
Dim idx As Long
Dim I As Long
idx = cboDept1.ListIndex
If idx <> -1 Then
With Sheet3
For I = 3 To 22
Me.Controls("Label" & I + 12).Caption = .Range("C" & I).Offset(0, idx).Text
Next I
End With
End If
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdClearForm_Click()
Call UserForm_Initialize
End Sub
Private Sub cmdOK4_Click()
Application.ScreenUpdating = False
Dim rng As Range, wd As Worksheet, r As Long
Set wd = ActiveWorkbook.Sheets("IndicatorDB")
r = wd.Range("A" & Rows.Count).End(xlUp).Row
For I = 1 To 20
If Me.Controls("TextBox" & I).Value <> "" Then
r = r + 1: Set rng = wd.Range("A" & r)
rng.Offset(-1, 0).EntireRow.Copy: rng.PasteSpecial xlPasteFormulas
rng.Value = cboName1.Value
rng.Offset(0, 1) = cboDept1.Value
rng.Offset(0, 2).Value = Me.Controls("Label" & I + 14).Caption
rng.Offset(0, 3).Value = DTPicker4.Value
rng.Offset(0, 4).Value = Me.Controls("TextBox" & I).Value
Set rng = rng.Offset(1)
End If
Next I
Sheets("Forms").Select
Unload Me
UserForm2.Show
Application.ScreenUpdating = True
End Sub
Private Sub UserForm_Initialize()
With Worksheets("ADMIN")
cboDept1.List = .Range("F4", .Range("F" & Rows.Count).End(xlUp)).Value
End With
With Worksheets("Employees")
cboName1.List = .Range("A1", .Range("A" & Rows.Count).End(xlUp)).Value
End With
End Sub
Sub SlowWithFlicker()
Dim rCell As Range
For Each rCell In Range("A1:A15000")
rCell.Select
Next rCell
End Sub
Sub FastWithNoFlicker()
Dim rCell As Range
Application.ScreenUpdating = False
For Each rCell In Range("A1:A15000")
rCell.Select
Next rCell
Application.ScreenUpdating = True
End Sub
Bookmarks