Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Print Sheet Array from List Box

I am getting hung up with the code below using a sheet array. For some
reason, xl is not recognizing the string. I have added quotes before and
after . . . still not working. The problem area is designated with "=".

Please help,
Stan


Private Sub CommandButton1_Click()
Dim L As Long
Dim zlist As String
Dim zLabel1 As String

zLabel1 = """, """
For L = 0 To SelectBox.ListCount - 1
If SelectBox.Selected(L) Then
alist = SelectBox.List(L)
Sheets(alist).Select
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = Sheets("Front Page").Range("title")
.RightHeader = ""
.LeftFooter = Sheets("Front Page").Range("stamp")
.CenterFooter = ""
.RightFooter = "&T &P of &PAGES"
End With
zlist = zlist & SelectBox.List(L)
If SelectBox.ListIndex < L Then zlist = zlist & zLabel1
End If
Next
zlist = """" & zlist
zlist = zlist & """"
Unload UserForm4

=Sheets(Array(zlist)).Select

ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default Print Sheet Array from List Box

Hi,

In the loop, build a comma-separated string -- with NO quote surrounding the
string:
'build string: sheet1,sheet2,...
For .............
zlist= zlist & SelectBox.List(L) & ","
Next
'remove last comma
If right(zlist,1) = "," then zlist = left(zlist,len(zlist)-1)

At this point, the only thing you have is a string. If you do Array(zlist)
you only get an array containing 1 element being the string zlist.
To get an array with each sheet name being an element of the array, use the
split function:
Sheets(Split(zlist,",")).Select

--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"StanJ" wrote:

I am getting hung up with the code below using a sheet array. For some
reason, xl is not recognizing the string. I have added quotes before and
after . . . still not working. The problem area is designated with "=".

Please help,
Stan


Private Sub CommandButton1_Click()
Dim L As Long
Dim zlist As String
Dim zLabel1 As String

zLabel1 = """, """
For L = 0 To SelectBox.ListCount - 1
If SelectBox.Selected(L) Then
alist = SelectBox.List(L)
Sheets(alist).Select
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = Sheets("Front Page").Range("title")
.RightHeader = ""
.LeftFooter = Sheets("Front Page").Range("stamp")
.CenterFooter = ""
.RightFooter = "&T &P of &PAGES"
End With
zlist = zlist & SelectBox.List(L)
If SelectBox.ListIndex < L Then zlist = zlist & zLabel1
End If
Next
zlist = """" & zlist
zlist = zlist & """"
Unload UserForm4

=Sheets(Array(zlist)).Select

ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Print Sheet Array from List Box

Thank you. This worked first time through.

"sebastienm" wrote:

Hi,

In the loop, build a comma-separated string -- with NO quote surrounding the
string:
'build string: sheet1,sheet2,...
For .............
zlist= zlist & SelectBox.List(L) & ","
Next
'remove last comma
If right(zlist,1) = "," then zlist = left(zlist,len(zlist)-1)

At this point, the only thing you have is a string. If you do Array(zlist)
you only get an array containing 1 element being the string zlist.
To get an array with each sheet name being an element of the array, use the
split function:
Sheets(Split(zlist,",")).Select

--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"StanJ" wrote:

I am getting hung up with the code below using a sheet array. For some
reason, xl is not recognizing the string. I have added quotes before and
after . . . still not working. The problem area is designated with "=".

Please help,
Stan


Private Sub CommandButton1_Click()
Dim L As Long
Dim zlist As String
Dim zLabel1 As String

zLabel1 = """, """
For L = 0 To SelectBox.ListCount - 1
If SelectBox.Selected(L) Then
alist = SelectBox.List(L)
Sheets(alist).Select
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = Sheets("Front Page").Range("title")
.RightHeader = ""
.LeftFooter = Sheets("Front Page").Range("stamp")
.CenterFooter = ""
.RightFooter = "&T &P of &PAGES"
End With
zlist = zlist & SelectBox.List(L)
If SelectBox.ListIndex < L Then zlist = zlist & zLabel1
End If
Next
zlist = """" & zlist
zlist = zlist & """"
Unload UserForm4

=Sheets(Array(zlist)).Select

ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
List and subtotal selected items, then print separate item list TitanG Excel Worksheet Functions 0 September 8th 08 09:07 PM
Array Formulas - Unique List from List with Duplicates Johnny Meredith Excel Discussion (Misc queries) 7 October 27th 06 09:26 PM
Active cell counting in particular print page (one sheet having different print area) ananthmca2004 Excel Worksheet Functions 1 November 24th 05 11:29 AM
Why do I get a print error light trying to print an excel sheet ? SMC Excel Discussion (Misc queries) 2 November 5th 05 01:36 AM
Sheet(Array( Won't print as I expect it to [email protected] Excel Worksheet Functions 0 June 21st 05 11:34 AM


All times are GMT +1. The time now is 09:02 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"