MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Formula or function related to counting columns

Posted by Todd Kasenberg on July 18, 2001 11:11 AM

I have developed a Gannt chart worksheet that, due to the nature of the projects, has variable start and stop dates, and therefore, variable project durations.
This poses problems for me,because I wish to print the Gannt chart, but only the area of the chart that has data in it. In other words, I only need to print to the last shaded cell.

I can compute how many day-by-day cells there are in the Gantt chart - that is easy. But how do I tell Excel, in selecting the range, to move over X number of columns, and print only to there, and not beyond?

Posted by IML on July 18, 2001 12:35 PM

I may be missing this, but lets say you want to print from cell A1 to a variable number of columns over. Let say the number of columns you want to pring in cell X1. Go to Insert, names, define and select Print_Area. In the refers box type the following formula

The first argument in the address is setting this at 10 rows, you can adjust this to how many rows you need printed.

Good luck.

Posted by Todd Kasenberg on July 19, 2001 8:47 AM

I will have to try this approach. Now, the big question is, how might I incorporate this suggestion into a macro?

Posted by IML on July 19, 2001 9:56 AM

If this does work for you, I'd repost a message with a subject along the lines of "creating a dynamic print range via vba"
Good luck.