03856me
Active Member
- Joined
- Apr 4, 2008
- Messages
- 297
I am using Excel 2013, and have setup multiple userforms that work fine, until I add a ListBox. I am familiar with userforms and have setup 100's in 2003-2007 with no problems that include listboxes that refresh after data is added. Using 2013, if I use the same method and code, it crashes and reboots Excel every time.
Am I missing something in the code that must be added or modified in 2010-2013?
FYI - opening prior workbooks in Excel 2013 execute properly without modification, it is just setting up new listboxes that create the problem.
The code is attached to my Add command button. Any help is greatly appreciated.
Am I missing something in the code that must be added or modified in 2010-2013?
FYI - opening prior workbooks in Excel 2013 execute properly without modification, it is just setting up new listboxes that create the problem.
The code is attached to my Add command button. Any help is greatly appreciated.
Code:
'===== Add Button ======================
Private Sub cmd_add_Click()
AddData
ClearData
Dim strRowSource As String
With lstState
strRowSource = .RowSource
.RowSource = vbNullString
.RowSource = strRowSource
End With
End Sub
'===== Add Data =====================
Private Sub AddData()
Dim iRow As Long
Dim WS As Worksheet
Set WS = Worksheets("lookups")
iRow = WS.Cells(Rows.Count, 19) _
.End(xlUp).Offset(1, 0).Row
WS.Cells(iRow, 19).Value = Me.txt_state.Value
Application.ScreenUpdating = True
End Sub