aka_krakur
Active Member
- Joined
- Jan 31, 2006
- Messages
- 438
I have a userform that for selections made by user there is VB written to send this info to certain fields on the Excel Spreadsheet:
here is an example of that code:
There came up a scenario that if the user either intentionally or accidentally didn't select anything from the list box the VB Code will bail because it's looking for something to fille in Row 6 (Starting in field B6).
So is there a way to insert another if statment that if value = "" to skip?
here is an example of that code:
Code:
'Fill in Criteria as selected
'Device Code
Dim i As Long, N As Long, a()
With CriteriaForm1.DeviceCodeListBox
For i = 0 To DeviceCodeListBox.ListCount - 1
If DeviceCodeListBox.Selected(i) Then
ReDim Preserve a(N)
a(N) = DeviceCodeListBox.List(i)
N = N + 1
End If
Next
End With
Sheets("ReportableQuery").Range("B6").Resize(, N) = a
There came up a scenario that if the user either intentionally or accidentally didn't select anything from the list box the VB Code will bail because it's looking for something to fille in Row 6 (Starting in field B6).
So is there a way to insert another if statment that if value = "" to skip?