Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 407
Default printing to a computed column

I have the following macro below that prints out from column A thru DS (at
least it does without the first two lines of code (using "lastcolumn") that
I just added because I want you to help me integrate them into the macro).
It works fine, but in most cases, many of the rightmost columns to the right
are all zeroes, etc. In that case, I want to use a parameter to tell it to
only print the first so many leftmost columns.

Sub PrintTotalCFCityView()


Dim lastcolumn
lastcolumn = Max(Sheets("totalCF").Range("C405"),
Sheets("totalCF").Range("C408"),119).



Sheets("TotalCF").Select
Range("A1:DS431").Select
Selection.Printout Copies:=1, Collate:=True
Application.Goto Reference:="R1C1"
Range("A3").Select

End Sub

Columns A thru C always get printed and, beginning in column D, in the first
row, is a counter that counts the number of months from left to right. So,
cell D1 shows 0 (for month zero) and Cell E1 shows 1, cell F1 shows 2 ...
column DS shows 119.

Hoping that my syntax is correct for the "lastcolumn" variable above, I'd
like to use that variable (which should produce a number like, say, 44) to
replace the DS column in the macro.

So, if "lastcolumn" were equal to 1, for example, I would want to print only
columns A thru E, if 2, columns A thru F, if 119, then I would want to
print all the way to column DS.

Can someone add to/rewrite the macro above, so the DS341 is changed to row
341 of a column that varies as just described, using the "lastcolumn"
dimensioned variable? Thank you very much.

Dean


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default printing to a computed column

Maybe...


Option Explicit
Sub PrintTotalCFCityView()
Dim lastcolumn As Long

With Worksheets("totalcf")
lastcolumn = Application.Max(.Range("C405").Value, _
.Range("C408").value, _
119)
.Range("A1", .Cells(431, lastcolumn + 4)).PrintOut _
Copies:=1, Collate:=True
End With

End Sub

Untested, uncompiled.


Dean wrote:

I have the following macro below that prints out from column A thru DS (at
least it does without the first two lines of code (using "lastcolumn") that
I just added because I want you to help me integrate them into the macro).
It works fine, but in most cases, many of the rightmost columns to the right
are all zeroes, etc. In that case, I want to use a parameter to tell it to
only print the first so many leftmost columns.

Sub PrintTotalCFCityView()

Dim lastcolumn
lastcolumn = Max(Sheets("totalCF").Range("C405"),
Sheets("totalCF").Range("C408"),119).

Sheets("TotalCF").Select
Range("A1:DS431").Select
Selection.Printout Copies:=1, Collate:=True
Application.Goto Reference:="R1C1"
Range("A3").Select

End Sub

Columns A thru C always get printed and, beginning in column D, in the first
row, is a counter that counts the number of months from left to right. So,
cell D1 shows 0 (for month zero) and Cell E1 shows 1, cell F1 shows 2 ...
column DS shows 119.

Hoping that my syntax is correct for the "lastcolumn" variable above, I'd
like to use that variable (which should produce a number like, say, 44) to
replace the DS column in the macro.

So, if "lastcolumn" were equal to 1, for example, I would want to print only
columns A thru E, if 2, columns A thru F, if 119, then I would want to
print all the way to column DS.

Can someone add to/rewrite the macro above, so the DS341 is changed to row
341 of a column that varies as just described, using the "lastcolumn"
dimensioned variable? Thank you very much.

Dean


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 407
Default printing to a computed column

Yup, that worked well. Thanks, Dave!
Dean

"Dave Peterson" wrote in message
...
Maybe...


Option Explicit
Sub PrintTotalCFCityView()
Dim lastcolumn As Long

With Worksheets("totalcf")
lastcolumn = Application.Max(.Range("C405").Value, _
.Range("C408").value, _
119)
.Range("A1", .Cells(431, lastcolumn + 4)).PrintOut _
Copies:=1, Collate:=True
End With

End Sub

Untested, uncompiled.


Dean wrote:

I have the following macro below that prints out from column A thru DS
(at
least it does without the first two lines of code (using "lastcolumn")
that
I just added because I want you to help me integrate them into the
macro).
It works fine, but in most cases, many of the rightmost columns to the
right
are all zeroes, etc. In that case, I want to use a parameter to tell it
to
only print the first so many leftmost columns.

Sub PrintTotalCFCityView()

Dim lastcolumn
lastcolumn = Max(Sheets("totalCF").Range("C405"),
Sheets("totalCF").Range("C408"),119).

Sheets("TotalCF").Select
Range("A1:DS431").Select
Selection.Printout Copies:=1, Collate:=True
Application.Goto Reference:="R1C1"
Range("A3").Select

End Sub

Columns A thru C always get printed and, beginning in column D, in the
first
row, is a counter that counts the number of months from left to right.
So,
cell D1 shows 0 (for month zero) and Cell E1 shows 1, cell F1 shows 2
...
column DS shows 119.

Hoping that my syntax is correct for the "lastcolumn" variable above, I'd
like to use that variable (which should produce a number like, say, 44)
to
replace the DS column in the macro.

So, if "lastcolumn" were equal to 1, for example, I would want to print
only
columns A thru E, if 2, columns A thru F, if 119, then I would want to
print all the way to column DS.

Can someone add to/rewrite the macro above, so the DS341 is changed to
row
341 of a column that varies as just described, using the "lastcolumn"
dimensioned variable? Thank you very much.

Dean


--

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
Computed value returning#VALUE Kennedy Excel Discussion (Misc queries) 5 March 23rd 10 06:41 PM
cell values being computed Matthew Bradford Excel Worksheet Functions 4 May 14th 07 04:43 PM
How do I sort a column of computed variables in EXCEL? Sylgeox Excel Worksheet Functions 2 October 3rd 05 12:07 AM
VLOOKUP - computed go to maceudora Excel Worksheet Functions 1 September 26th 05 01:00 AM
largest factorial that can be computed Loane Sharp[_2_] Excel Programming 3 August 15th 05 09:34 AM


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