Create a New Workbook based on VBA mulitselect listbox items

LizCorbert

New Member
Joined
Oct 29, 2014
Messages
25
I finally resolved prior issues regarding having selected items from a multiselect listbox recognize the defined arrays. However, now I am faced with a new issue, now the results from the selected arrays do not generate a new workbook. Now the results are generated in the workbook containing the macro. When the selections are changed the results do change, however, the magic occurs within the workbook containing the macro instead of producing a new workbook. Can someone please help me to re-establish that the results will generate new workbooks. PLEASE! See revised code.


Dim I As Long​
Dim A As Long​
A = Me.Submissionlist.Selected(0) & (1)​

Dim selCount As Long​
selCount = -1​

Dim wbNew As Workbook​
Set wbNew = ActiveWorkbook.Workbooks​

For I = 0 To Me.Submissionlist.ListCount - 1​
If Me.Submissionlist.Selected(I) Then​
Sheets("SubmissionProperty").Visible = False​
ThisWorkbook.Worksheets(Array("Client_Profile" & "SubmissionProperty")).Copy​
Sheets("SubmissionProperty").Visible = True​
Worksheets("Client_Profile").Move Before:=Worksheets(1)​
Worksheets("Client_Profile").Activate​
End If​
If selCount = -1 Then​
Me.Submissionlist.Selected(I) = False​
Me.Submissionlist.Clear​
End If​
Exit For​
Next​
If Me.Submissionlist.Selected(1) Then​
Sheets("SubmissionLiabilty").Visible = False​
ThisWorkbook.Worksheets(Array("Client_Profile" & "SubmissionLiabilty")).Copy​
Sheets("SubmissionLiabilty").Visible = True​
Worksheets("Client_Profile").Move Before:=Worksheets(1)​
Worksheets("Client_Profile").Activate​
End If​
If selCount = -1 Then​
Me.Submissionlist.Selected(1) = False​
Me.Submissionlist.Clear​
End If​
If Me.Submissionlist.Selected(A) Then​
Sheets("SubmissionProperty").Visible = False​
Sheets("SubmissionLiabilty").Visible = False​
ThisWorkbook.Worksheets(Array("Client_Profile" & "SubmissionProperty" & "SubmissionLiabilty")).Copy​
Sheets("SubmissionProperty").Visible = True​
Sheets("SubmissionLiabilty").Visible = True​
Worksheets("Client_Profile").Move Before:=Worksheets(1)​
Worksheets("Client_Profile").Activate​
End If​
If selCount = -1 Then​
Me.Submissionlist.Selected(A) = False​
Me.Submissionlist.Clear​
End If​
If Me.Submissionlist.Value Then Unload Me​
Application.ScreenUpdating = True​

End Sub​
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,215,430
Messages
6,124,850
Members
449,194
Latest member
HellScout

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top