C.R.
11-05-2014, 11:10 AM
Hello,
I have a user form that is used to select worksheets to print.
I am trying to adapt it to load text files for worksheets that are selected in the user form.
This is for a workbook that is used for sales reporting at the end of each workday for our company.
There are 50 SAP text files that are loaded to this workbook.
Sometimes, a user may forget to run one or more of the reports.
So the thought is, with the user form, the user could just run the missing report in SAP, and launch the user form to load it.
Since each worksheet loads a different text file maybe a Case Statement? Not sure.
Private Sub CommandButton2_Click()
Dim iloop As Integer
For iloop = 1 To ListBox1.ListCount
If ListBox1.Selected(iloop - 1) = True Then
'|||||||||||||||||||||||||||||||||||||||||||||
Sheets(ListBox1.List(iloop - 1, 0)).PrintOut '(Change this part to load text files)
'|||||||||||||||||||||||||||||||||||||||||||||
ListBox1.Selected(iloop - 1) = False
End If
Next
'ActiveWorkbook.Connections("test_data").Refresh
End Sub
I cannot seem to get this to work. A sample Workbook is attached.
Thanks in advance for any suggestions…
C.R.
I have a user form that is used to select worksheets to print.
I am trying to adapt it to load text files for worksheets that are selected in the user form.
This is for a workbook that is used for sales reporting at the end of each workday for our company.
There are 50 SAP text files that are loaded to this workbook.
Sometimes, a user may forget to run one or more of the reports.
So the thought is, with the user form, the user could just run the missing report in SAP, and launch the user form to load it.
Since each worksheet loads a different text file maybe a Case Statement? Not sure.
Private Sub CommandButton2_Click()
Dim iloop As Integer
For iloop = 1 To ListBox1.ListCount
If ListBox1.Selected(iloop - 1) = True Then
'|||||||||||||||||||||||||||||||||||||||||||||
Sheets(ListBox1.List(iloop - 1, 0)).PrintOut '(Change this part to load text files)
'|||||||||||||||||||||||||||||||||||||||||||||
ListBox1.Selected(iloop - 1) = False
End If
Next
'ActiveWorkbook.Connections("test_data").Refresh
End Sub
I cannot seem to get this to work. A sample Workbook is attached.
Thanks in advance for any suggestions…
C.R.