Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Print Array in Cell

I have a list of sheets in cell A1:-

"Index", "Area 1", "Area 2"

I want to create a macro that will print out these sheets, some thin
like

sheetrange = range("a1")
sheets(array(sheetrange)).select
selectedsheets.printpreview

can someone help me out on this one

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Print Array in Cell

With worksheets("Sheet1")
varr = Split(.Range("A1"))
End With
sheets(varr).Select
ActiveWindows.SelectedSheets.PrintPreview

Works in xl2000 or later.

--
Regards,
Tom Ogilvy

"ianripping " wrote in message
...
I have a list of sheets in cell A1:-

"Index", "Area 1", "Area 2"

I want to create a macro that will print out these sheets, some thing
like

sheetrange = range("a1")
sheets(array(sheetrange)).select
selectedsheets.printpreview

can someone help me out on this one?


--- Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Print Array in Cell

I havent tested this, but maybe something like:

Sub testSub()
mySheets = Split(Sheets("Sheet1").Range("A1").Value, ",")
For i = 0 To UBound(mySheets)
mySheets(i) = Replace(mySheets(i), """", "")
'MsgBox mySheets(i)
Sheets(mySheets(i)).PrintOut
Next i
End Sub

Change "Sheet1" to whatever sheet you keep your array in - try it ou

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Print Array in Cell

I left off the second argument for split
With worksheets("Sheet1")
varr = Split(.Range("A1"),",")
End With
sheets(varr).Select
ActiveWindows.SelectedSheets.PrintPreview


it would be easier to adjust the values in A1 to be

Index,Area 1,Area 2

rather than to write code to eliminate the doublequotes. Particularly since
you will probably be changing this list frequently.

--
Regards,
Tom Ogilvy



"sp00nix " wrote in message
...
I havent tested this, but maybe something like:

Sub testSub()
mySheets = Split(Sheets("Sheet1").Range("A1").Value, ",")
For i = 0 To UBound(mySheets)
mySheets(i) = Replace(mySheets(i), """", "")
'MsgBox mySheets(i)
Sheets(mySheets(i)).PrintOut
Next i
End Sub

Change "Sheet1" to whatever sheet you keep your array in - try it out


---
Message posted from http://www.ExcelForum.com/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Print Array in Cell

I have tried both of these methods, but the problem is i get acompli
error "Sub or function not defined" for Split.

I am running excel 97. Could this be the problem that the Spli
function isnt supported?

If so, what can I do

--
Message posted from http://www.ExcelForum.com



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Print Array in Cell

Works in xl2000 or later.

was in my original post. Split wasn't introduce until Excel 2000.

You could do this

Sub tester3()
With Worksheets("Sheet1")
sStr = .Range("A1")
End With
varr = Evaluate("{" & sStr & "}")
Sheets(varr).Select
ActiveWindow.SelectedSheets.PrintPreview
End Sub

This assume you use your original format in the cell with the double quotes:
"Index", "Area 1", "Area 2"

--
Regards,
Tom Ogilvy




"ianripping " wrote in message
...
I have tried both of these methods, but the problem is i get acomplie
error "Sub or function not defined" for Split.

I am running excel 97. Could this be the problem that the Split
function isnt supported?

If so, what can I do?


---
Message posted from http://www.ExcelForum.com/



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
Prevent cell/array references from changing when altering/moving thecell/array nme Excel Discussion (Misc queries) 1 September 19th 08 01:53 PM
cell borders that I create dont show on print preview or print scott3435 Excel Discussion (Misc queries) 2 April 6th 06 02:37 AM
Print Array for hidden sheets using VBA Ant Excel Discussion (Misc queries) 1 March 27th 06 11:24 AM
Print Array for hidden sheets using VBA Ant Excel Discussion (Misc queries) 0 March 22nd 06 04:31 PM
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 01:40 PM.

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

About Us

"It's about Microsoft Excel"