Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Range is not being picked up


Please take a look at my code, I am trying to pick up the range and
print it, depending on the analysis years.

Dim area As String
Dim startrow(1) As Integer
Dim startcol(1) As Integer
Dim endrow(1) As Integer
Dim endcol(1) As Integer
Dim vern_startrow(1) As Integer
Dim vern_startcol(1) As Integer
Dim vern_endrow(1) As Integer
Dim vern_endcol(1) As Integer

fstyr = Range("FirstAll")
lstyr = Range("LastAll")

Sheets("Personal P_L").Select
For i = 1 To 15
startrow(1) = 1
startcol(1) = 20 'T
endrow(1) = 56 + 2 * (lstyr - fstyr)
endcol(1) = 46 'AT
With ActiveSheet.PageSetup
..Orientation = xlLandscape
..PaperSize = xlPaperLegal
..Range(.Cells(startrow, startcol), .Cells(endrow,
endcol)).Select
End With
Selection.PrintOut Copies:=1, Collate:=True
Next i

It gives me an error regarding my Range function...any help???

Thanks!


--
Sheeny
------------------------------------------------------------------------
Sheeny's Profile: http://www.excelforum.com/member.php...fo&userid=9082
View this thread: http://www.excelforum.com/showthread...hreadid=538967

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Range is not being picked up

Are you writing about this line:

..Range(.Cells(startrow, startcol), .Cells(endrow, endcol)).Select

(assuming that the leading dot got eaten by the posting)

..range and both .cells() reference don't belong to the activesheet.pagesetup
property. They belong to something that can hold a range--like a worksheet.

And I'm not sure why you tried to use arrays for your variables. And as a rule,
I never use Integer. Integers can only go to +/- 32k (about). But you can have
rows up to 65536 (64k).

And you don't need to select stuff (worksheets or ranges) to work with them.

I'm not sure if this does what you intended, but it did compile for me:

Option Explicit
Sub testme()

Dim StartRow As Long
Dim StartCol As Long
Dim EndRow As Long
Dim EndCol As Long
Dim i As Long

Dim FstYr As Double
Dim LstYr As Double

With Worksheets("Personal P_L")
FstYr = .Range("FirstAll").Value
LstYr = .Range("LastAll").Value

'these don't change, so don't put them in the loop.
With .PageSetup
.Orientation = xlLandscape
.PaperSize = xlPaperLegal
End With

StartRow = 1
StartCol = 20 'T
EndCol = 46 'AT
EndRow = 56 + 2 * (LstYr - FstYr)

'why not just print once and make copies:=15????
For i = 1 To 15
.Range(.Cells(StartRow, StartCol), _
.Cells(EndRow, EndCol)).PrintOut Copies:=1, Collate:=True
Next i

End With
End Sub


Sheeny wrote:

Please take a look at my code, I am trying to pick up the range and
print it, depending on the analysis years.

Dim area As String
Dim startrow(1) As Integer
Dim startcol(1) As Integer
Dim endrow(1) As Integer
Dim endcol(1) As Integer
Dim vern_startrow(1) As Integer
Dim vern_startcol(1) As Integer
Dim vern_endrow(1) As Integer
Dim vern_endcol(1) As Integer

fstyr = Range("FirstAll")
lstyr = Range("LastAll")

Sheets("Personal P_L").Select
For i = 1 To 15
startrow(1) = 1
startcol(1) = 20 'T
endrow(1) = 56 + 2 * (lstyr - fstyr)
endcol(1) = 46 'AT
With ActiveSheet.PageSetup
Orientation = xlLandscape
PaperSize = xlPaperLegal
Range(.Cells(startrow, startcol), .Cells(endrow,
endcol)).Select
End With
Selection.PrintOut Copies:=1, Collate:=True
Next i

It gives me an error regarding my Range function...any help???

Thanks!

--
Sheeny
------------------------------------------------------------------------
Sheeny's Profile: http://www.excelforum.com/member.php...fo&userid=9082
View this thread: http://www.excelforum.com/showthread...hreadid=538967


--

Dave Peterson
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
how do you have 2 criterias be picked up in a lookup? N. Vu Excel Worksheet Functions 5 June 30th 09 11:57 PM
Posts not getting picked up T. Valko Excel Discussion (Misc queries) 5 March 28th 07 01:58 AM
Range is not being picked up Sheeny[_25_] Excel Programming 1 May 4th 06 07:55 PM
For each picked entitiy in a list box... Ctech[_115_] Excel Programming 8 March 21st 06 05:28 PM
Just a tip I have picked-up Beto[_3_] Excel Programming 2 February 5th 04 09:13 PM


All times are GMT +1. The time now is 04:27 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"