ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,737
- Office Version
- 2007
- Platform
- Windows
Evening,
I have a button which when pressed just opens a userform.
I press the button & straight away i see the outer border etc of the userform quite some seconds etc before the button,form color etc etc is even shown.
Im not sure what code you need to look at so i have supplied some below if you could advise please.
I have a button which when pressed just opens a userform.
I press the button & straight away i see the outer border etc of the userform quite some seconds etc before the button,form color etc etc is even shown.
Im not sure what code you need to look at so i have supplied some below if you could advise please.
Code:
Private Sub UserForm_Initialize()'Modified 10/3/2018 5:51:42 AM EDT
Application.ScreenUpdating = False
Dim LastRow As Long
LastRow = Sheets("POSTAGE").Cells(Rows.Count, "B").End(xlUp).Row
Dim Lastrowa As Long
Sheets("POSTAGE").Cells(8, 2).Resize(LastRow - 7).Copy Sheets("POSTAGE").Cells(1, 12)
Lastrowa = Sheets("POSTAGE").Cells(Rows.Count, "L").End(xlUp).Row
Sheets("POSTAGE").Cells(1, 12).Resize(Lastrowa).Sort key1:=Cells(1, 12).Resize(Lastrowa), order1:=xlAscending, Header:=xlNo
CustomerSearchBox.List = Sheets("POSTAGE").Cells(1, 12).Resize(Lastrowa).Value
ListBox1.List = Sheets("POSTAGE").Cells(1, 12).Resize(Lastrowa).Value
Sheets("POSTAGE").Cells(1, 12).Resize(Lastrowa).Clear
Application.ScreenUpdating = True
'USERNAME COMBOBOX
TextBox1.Value = Format(CDbl(Date), "dd/mm/yyyy")
TextBox2.SetFocus
End Sub
Code:
Private Sub UserForm_Activate() 'Dantes code
'ListBox1.RowSource = "B:B" & Range("B" & Rows.Count).End(xlUp).Row
Dim i As Long, j As Long, ws As Worksheet
Set ws = Sheets("POSTAGE")
For i = 8 To ws.Range("B" & Rows.Count).End(xlUp).Row
added = False
For j = 0 To ListBox1.ListCount - 1
Select Case StrComp(ListBox1.List(j), ws.Cells(i, "B").Value, vbTextCompare)
Case 0: added = True: Exit For
Case 1: added = True: ListBox1.AddItem ws.Cells(i, "B").Value, j
Exit For
End Select
Next
If added = False Then ListBox1.AddItem ws.Cells(i, "B").Value
Next
End Sub
Code: