Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Printing worksheet excluding rows with formulas

My worksheet has data in columns A to M. Data has been entered up to
Row 35, but there are "If" formulas in column D which extend down to
Row 200. I have inserted a macro to select and print the area with data,
which is up to Row 35. However, the print area selected by the macro
is A1:M200. Apparently this is happening because the "If"
formulas extend to Row 200.
I would be thankful for any help I can get in getting the macro to select
the required print range A1:M35
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Printing worksheet excluding rows with formulas

Show the code that determines the area to be printed and perhaps someone can
suggest something.

Otherwise

set rng = Range(Cells(rows.count,1).end(xlup), Range("M1"))
rng.printout


--
Regards,
Tom Ogilvy

"LennyG" wrote in message
...
My worksheet has data in columns A to M. Data has been entered up to
Row 35, but there are "If" formulas in column D which extend down to
Row 200. I have inserted a macro to select and print the area with

data,
which is up to Row 35. However, the print area selected by the macro
is A1:M200. Apparently this is happening because the "If"
formulas extend to Row 200.
I would be thankful for any help I can get in getting the macro to select
the required print range A1:M35



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Printing worksheet excluding rows with formulas

Hi Tom,
The code which selects the print area includes as follows
Dim NDates As Integer, NHeads As Integer
With Range("A1")
NHeads = Range(.Offset(0,1),.End(xlToRight)).Columns.Count
NDates = Range(.Offset(1,0),.End(xlDown)).Rows.Count
Range(.Offset0,0).Offset(NDates,NHeads).Name = "EntireDataSet"
End With
ActiveSheet.PageSetUp.PrintArea = Range("EntireDataSet").Address

Hoping That the above will help.
Regards ,

"Tom Ogilvy" wrote:

Show the code that determines the area to be printed and perhaps someone can
suggest something.

Otherwise

set rng = Range(Cells(rows.count,1).end(xlup), Range("M1"))
rng.printout


--
Regards,
Tom Ogilvy

"LennyG" wrote in message
...
My worksheet has data in columns A to M. Data has been entered up to
Row 35, but there are "If" formulas in column D which extend down to
Row 200. I have inserted a macro to select and print the area with

data,
which is up to Row 35. However, the print area selected by the macro
is A1:M200. Apparently this is happening because the "If"
formulas extend to Row 200.
I would be thankful for any help I can get in getting the macro to select
the required print range A1:M35




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Printing worksheet excluding rows with formulas

Your code gave me an error, but if I changed it to

Sub AA()
Dim NDates As Integer, NHeads As Integer
With Range("A1")
NHeads = Range(.Offset(0, 1), .End(xlToRight)).Columns.Count
NDates = Range(.Offset(1, 0), .End(xlDown)).Rows.Count
Range(.Offset(0, 0), .Offset(NDates, NHeads)).Name = "EntireDataSet"
End With
ActiveSheet.PageSetUp.PrintArea = Range("EntireDataSet").Address
End Sub

It worked for me and wasn't affected by formulas in column D.

--
Regards,
Tom Ogilvy


"LennyG" wrote in message
...
Hi Tom,
The code which selects the print area includes as follows
Dim NDates As Integer, NHeads As Integer
With Range("A1")
NHeads = Range(.Offset(0,1),.End(xlToRight)).Columns.Count
NDates = Range(.Offset(1,0),.End(xlDown)).Rows.Count
Range(.Offset0,0).Offset(NDates,NHeads).Name = "EntireDataSet"
End With
ActiveSheet.PageSetUp.PrintArea = Range("EntireDataSet").Address

Hoping That the above will help.
Regards ,

"Tom Ogilvy" wrote:

Show the code that determines the area to be printed and perhaps someone

can
suggest something.

Otherwise

set rng = Range(Cells(rows.count,1).end(xlup), Range("M1"))
rng.printout


--
Regards,
Tom Ogilvy

"LennyG" wrote in message
...
My worksheet has data in columns A to M. Data has been entered up to
Row 35, but there are "If" formulas in column D which extend down to
Row 200. I have inserted a macro to select and print the area with

data,
which is up to Row 35. However, the print area selected by the macro
is A1:M200. Apparently this is happening because the "If"
formulas extend to Row 200.
I would be thankful for any help I can get in getting the macro to

select
the required print range A1:M35






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Printing worksheet excluding rows with formulas

Hi Tom,
Thanks for your assistance.
I also have in my code a line which gives the print area before I print
This line follows the "End With" previously shown
MsgBox"The entire data set is the range" & Range("EntireDataSet").Address, _
vbinformation, "Data Set Address."
I continue to get the response
"The entire data set is the range $A$1:$M$200"
If I delete the formulas in Col D Rows 191:200, the print area adjusts
to $A$1:$M$190, hence my suggestion that the formulas are the problem
Thanks again for your support.
Also , the previous lines sent to you were missing a second ")" after NHeads
and I suspect that is why you got the error

"Tom Ogilvy" wrote:

Your code gave me an error, but if I changed it to

Sub AA()
Dim NDates As Integer, NHeads As Integer
With Range("A1")
NHeads = Range(.Offset(0, 1), .End(xlToRight)).Columns.Count
NDates = Range(.Offset(1, 0), .End(xlDown)).Rows.Count
Range(.Offset(0, 0), .Offset(NDates, NHeads)).Name = "EntireDataSet"
End With
ActiveSheet.PageSetUp.PrintArea = Range("EntireDataSet").Address
End Sub

It worked for me and wasn't affected by formulas in column D.

--
Regards,
Tom Ogilvy


"LennyG" wrote in message
...
Hi Tom,
The code which selects the print area includes as follows
Dim NDates As Integer, NHeads As Integer
With Range("A1")
NHeads = Range(.Offset(0,1),.End(xlToRight)).Columns.Count
NDates = Range(.Offset(1,0),.End(xlDown)).Rows.Count
Range(.Offset0,0).Offset(NDates,NHeads).Name = "EntireDataSet"
End With
ActiveSheet.PageSetUp.PrintArea = Range("EntireDataSet").Address

Hoping That the above will help.
Regards ,

"Tom Ogilvy" wrote:

Show the code that determines the area to be printed and perhaps someone

can
suggest something.

Otherwise

set rng = Range(Cells(rows.count,1).end(xlup), Range("M1"))
rng.printout


--
Regards,
Tom Ogilvy

"LennyG" wrote in message
...
My worksheet has data in columns A to M. Data has been entered up to
Row 35, but there are "If" formulas in column D which extend down to
Row 200. I have inserted a macro to select and print the area with
data,
which is up to Row 35. However, the print area selected by the macro
is A1:M200. Apparently this is happening because the "If"
formulas extend to Row 200.
I would be thankful for any help I can get in getting the macro to

select
the required print range A1:M35








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Printing worksheet excluding rows with formulas

Range(.Offset0,0).Offset(NDates,NHeads).Name = "EntireDataSet"
Range(.Offset(0, 0), .Offset(NDates, NHeads)).Name = "EntireDataSet"

There were a lot more problems than a missing paren.

Range(.Offset(0,0).Offset(NDates,NHeads)).Name

would refer to a single cell.

If column A can be used to determine the last row to be printed, then my
original suggestion would work:

set rng = Range(Cells(rows.count,1).end(xlup), Range("M1"))


set rng = Range(Cells(rows.count,1).end(xlup), Range("M1"))
? rng.Address
$A$1:$M$11


--
Regards,
Tom Ogilvy


"LennyG" wrote in message
...
Hi Tom,
Thanks for your assistance.
I also have in my code a line which gives the print area before I print
This line follows the "End With" previously shown
MsgBox"The entire data set is the range" & Range("EntireDataSet").Address,

_
vbinformation, "Data Set Address."
I continue to get the response
"The entire data set is the range $A$1:$M$200"
If I delete the formulas in Col D Rows 191:200, the print area adjusts
to $A$1:$M$190, hence my suggestion that the formulas are the problem
Thanks again for your support.
Also , the previous lines sent to you were missing a second ")" after

NHeads
and I suspect that is why you got the error

"Tom Ogilvy" wrote:

Your code gave me an error, but if I changed it to

Sub AA()
Dim NDates As Integer, NHeads As Integer
With Range("A1")
NHeads = Range(.Offset(0, 1), .End(xlToRight)).Columns.Count
NDates = Range(.Offset(1, 0), .End(xlDown)).Rows.Count
Range(.Offset(0, 0), .Offset(NDates, NHeads)).Name =

"EntireDataSet"
End With
ActiveSheet.PageSetUp.PrintArea = Range("EntireDataSet").Address
End Sub

It worked for me and wasn't affected by formulas in column D.

--
Regards,
Tom Ogilvy


"LennyG" wrote in message
...
Hi Tom,
The code which selects the print area includes as follows
Dim NDates As Integer, NHeads As Integer
With Range("A1")
NHeads = Range(.Offset(0,1),.End(xlToRight)).Columns.Count
NDates = Range(.Offset(1,0),.End(xlDown)).Rows.Count
Range(.Offset0,0).Offset(NDates,NHeads).Name = "EntireDataSet"
End With
ActiveSheet.PageSetUp.PrintArea = Range("EntireDataSet").Address

Hoping That the above will help.
Regards ,

"Tom Ogilvy" wrote:

Show the code that determines the area to be printed and perhaps

someone
can
suggest something.

Otherwise

set rng = Range(Cells(rows.count,1).end(xlup), Range("M1"))
rng.printout


--
Regards,
Tom Ogilvy

"LennyG" wrote in message
...
My worksheet has data in columns A to M. Data has been entered

up to
Row 35, but there are "If" formulas in column D which extend down

to
Row 200. I have inserted a macro to select and print the area

with
data,
which is up to Row 35. However, the print area selected by the

macro
is A1:M200. Apparently this is happening because the "If"
formulas extend to Row 200.
I would be thankful for any help I can get in getting the macro to

select
the required print range A1:M35








  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Printing worksheet excluding rows with formulas

Actually

Range(.Offset(0,0).Offset(NDates,NHeads)).Name

would refer to a single cell.


would be an error as well. Without the outer Range (which causes the
error), it would be
Sub CC()
NDates = 35
NHeads = 13
With Range("A1")
Debug.Print .Offset(0, 0).Offset(NDates, NHeads).Address
End With
End Sub

Which would return N36.

--
Regards,
Tom Ogilvy


"Tom Ogilvy" wrote in message
...
Range(.Offset0,0).Offset(NDates,NHeads).Name = "EntireDataSet"
Range(.Offset(0, 0), .Offset(NDates, NHeads)).Name = "EntireDataSet"

There were a lot more problems than a missing paren.

Range(.Offset(0,0).Offset(NDates,NHeads)).Name

would refer to a single cell.

If column A can be used to determine the last row to be printed, then my
original suggestion would work:

set rng = Range(Cells(rows.count,1).end(xlup), Range("M1"))


set rng = Range(Cells(rows.count,1).end(xlup), Range("M1"))
? rng.Address
$A$1:$M$11


--
Regards,
Tom Ogilvy


"LennyG" wrote in message
...
Hi Tom,
Thanks for your assistance.
I also have in my code a line which gives the print area before I print
This line follows the "End With" previously shown
MsgBox"The entire data set is the range" &

Range("EntireDataSet").Address,
_
vbinformation, "Data Set Address."
I continue to get the response
"The entire data set is the range $A$1:$M$200"
If I delete the formulas in Col D Rows 191:200, the print area adjusts
to $A$1:$M$190, hence my suggestion that the formulas are the problem
Thanks again for your support.
Also , the previous lines sent to you were missing a second ")" after

NHeads
and I suspect that is why you got the error

"Tom Ogilvy" wrote:

Your code gave me an error, but if I changed it to

Sub AA()
Dim NDates As Integer, NHeads As Integer
With Range("A1")
NHeads = Range(.Offset(0, 1), .End(xlToRight)).Columns.Count
NDates = Range(.Offset(1, 0), .End(xlDown)).Rows.Count
Range(.Offset(0, 0), .Offset(NDates, NHeads)).Name =

"EntireDataSet"
End With
ActiveSheet.PageSetUp.PrintArea = Range("EntireDataSet").Address
End Sub

It worked for me and wasn't affected by formulas in column D.

--
Regards,
Tom Ogilvy


"LennyG" wrote in message
...
Hi Tom,
The code which selects the print area includes as follows
Dim NDates As Integer, NHeads As Integer
With Range("A1")
NHeads = Range(.Offset(0,1),.End(xlToRight)).Columns.Count
NDates = Range(.Offset(1,0),.End(xlDown)).Rows.Count
Range(.Offset0,0).Offset(NDates,NHeads).Name = "EntireDataSet"
End With
ActiveSheet.PageSetUp.PrintArea = Range("EntireDataSet").Address

Hoping That the above will help.
Regards ,

"Tom Ogilvy" wrote:

Show the code that determines the area to be printed and perhaps

someone
can
suggest something.

Otherwise

set rng = Range(Cells(rows.count,1).end(xlup), Range("M1"))
rng.printout


--
Regards,
Tom Ogilvy

"LennyG" wrote in message
...
My worksheet has data in columns A to M. Data has been entered

up to
Row 35, but there are "If" formulas in column D which extend

down
to
Row 200. I have inserted a macro to select and print the area

with
data,
which is up to Row 35. However, the print area selected by the

macro
is A1:M200. Apparently this is happening because the "If"
formulas extend to Row 200.
I would be thankful for any help I can get in getting the macro

to
select
the required print range A1:M35










  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Printing worksheet excluding rows with formulas

Hi Tom,
I finally got it to work because of your suggestions.
Thanks again.

"Tom Ogilvy" wrote:

Actually

Range(.Offset(0,0).Offset(NDates,NHeads)).Name

would refer to a single cell.


would be an error as well. Without the outer Range (which causes the
error), it would be
Sub CC()
NDates = 35
NHeads = 13
With Range("A1")
Debug.Print .Offset(0, 0).Offset(NDates, NHeads).Address
End With
End Sub

Which would return N36.

--
Regards,
Tom Ogilvy


"Tom Ogilvy" wrote in message
...
Range(.Offset0,0).Offset(NDates,NHeads).Name = "EntireDataSet"
Range(.Offset(0, 0), .Offset(NDates, NHeads)).Name = "EntireDataSet"

There were a lot more problems than a missing paren.

Range(.Offset(0,0).Offset(NDates,NHeads)).Name

would refer to a single cell.

If column A can be used to determine the last row to be printed, then my
original suggestion would work:

set rng = Range(Cells(rows.count,1).end(xlup), Range("M1"))


set rng = Range(Cells(rows.count,1).end(xlup), Range("M1"))
? rng.Address
$A$1:$M$11


--
Regards,
Tom Ogilvy


"LennyG" wrote in message
...
Hi Tom,
Thanks for your assistance.
I also have in my code a line which gives the print area before I print
This line follows the "End With" previously shown
MsgBox"The entire data set is the range" &

Range("EntireDataSet").Address,
_
vbinformation, "Data Set Address."
I continue to get the response
"The entire data set is the range $A$1:$M$200"
If I delete the formulas in Col D Rows 191:200, the print area adjusts
to $A$1:$M$190, hence my suggestion that the formulas are the problem
Thanks again for your support.
Also , the previous lines sent to you were missing a second ")" after

NHeads
and I suspect that is why you got the error

"Tom Ogilvy" wrote:

Your code gave me an error, but if I changed it to

Sub AA()
Dim NDates As Integer, NHeads As Integer
With Range("A1")
NHeads = Range(.Offset(0, 1), .End(xlToRight)).Columns.Count
NDates = Range(.Offset(1, 0), .End(xlDown)).Rows.Count
Range(.Offset(0, 0), .Offset(NDates, NHeads)).Name =

"EntireDataSet"
End With
ActiveSheet.PageSetUp.PrintArea = Range("EntireDataSet").Address
End Sub

It worked for me and wasn't affected by formulas in column D.

--
Regards,
Tom Ogilvy


"LennyG" wrote in message
...
Hi Tom,
The code which selects the print area includes as follows
Dim NDates As Integer, NHeads As Integer
With Range("A1")
NHeads = Range(.Offset(0,1),.End(xlToRight)).Columns.Count
NDates = Range(.Offset(1,0),.End(xlDown)).Rows.Count
Range(.Offset0,0).Offset(NDates,NHeads).Name = "EntireDataSet"
End With
ActiveSheet.PageSetUp.PrintArea = Range("EntireDataSet").Address

Hoping That the above will help.
Regards ,

"Tom Ogilvy" wrote:

Show the code that determines the area to be printed and perhaps

someone
can
suggest something.

Otherwise

set rng = Range(Cells(rows.count,1).end(xlup), Range("M1"))
rng.printout


--
Regards,
Tom Ogilvy

"LennyG" wrote in message
...
My worksheet has data in columns A to M. Data has been entered

up to
Row 35, but there are "If" formulas in column D which extend

down
to
Row 200. I have inserted a macro to select and print the area

with
data,
which is up to Row 35. However, the print area selected by the

macro
is A1:M200. Apparently this is happening because the "If"
formulas extend to Row 200.
I would be thankful for any help I can get in getting the macro

to
select
the required print range A1:M35











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
Printing a worksheet with and without formulas showing Ineveraccepttheterms Excel Discussion (Misc queries) 1 March 13th 10 07:55 PM
Printing formulas in worksheet 05_CHASBRO Excel Worksheet Functions 3 August 1st 09 07:17 PM
How can I print a worksheet excluding blank rows? lohme Excel Worksheet Functions 13 August 23rd 06 10:36 PM
printing worksheet with hidden rows Latricia Excel Worksheet Functions 1 May 25th 06 05:09 PM
Printing formulas on a worksheet bakerdmw Excel Worksheet Functions 3 March 3rd 06 05:06 PM


All times are GMT +1. The time now is 03:50 AM.

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"