Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,564
- Office Version
- 365
- 2016
- Platform
- Windows
I am having trouble adapting my code to do what I need it to do. My Google searches hasn't provided me a clear understanding of what I need to do in my particular situiation.
I have a database that contains rows of data associated with different dates.
I have a listbox (lbx_datesel) on my userform that lists the different dates represented in the the database. This list is dynamic and can have one or more dates for the user to select.
The user selects one or more dates from the listbox.
When the user presses the SUBMIT button, I need the VBA to create a unique worksheet in the workbook to hold data exclusive to each date selected.
If three dates were selected, there would be three worksheets created (named: Core_Data_dd-mmm where dd and mm represents the day and month respectively of that selection being processed). Each worksheet would hold only the data for that selected date.
This is as far as I got ... and it doesn't work, for a single selection. Multiple selections are incomplete as I have no idea where to start.
Kindly asking for help or resources that can help me figure it out.
I have a database that contains rows of data associated with different dates.
I have a listbox (lbx_datesel) on my userform that lists the different dates represented in the the database. This list is dynamic and can have one or more dates for the user to select.
The user selects one or more dates from the listbox.
When the user presses the SUBMIT button, I need the VBA to create a unique worksheet in the workbook to hold data exclusive to each date selected.
If three dates were selected, there would be three worksheets created (named: Core_Data_dd-mmm where dd and mm represents the day and month respectively of that selection being processed). Each worksheet would hold only the data for that selected date.
This is as far as I got ... and it doesn't work, for a single selection. Multiple selections are incomplete as I have no idea where to start.
VBA Code:
Private Sub uf_proceed_Click()
Dim cnt As Long
Dim selectedRows As Collection
Dim selval, t
cnt = lbx_datesel.ListCount
If cnt = 1 Then
t = lbx_datesel.ListIndex
selval = lbx_datesel.Value
'eliminate all data from database other than what was selected.
'rename data worksheet Core_Data_dd-mmm
Else
'multiselect
'loop through all selected dates from listbox
'copy data for that unique date to a new worksheet and name it Core_Data_dd-mmm
'follow above procedure for each date selected from the list box
End If
End Sub
Kindly asking for help or resources that can help me figure it out.