Coding a dynamic print area

rmunsun1

New Member
Joined
Mar 7, 2011
Messages
4
All,

I am trying to code in a dynamic print area. I have a section of code that works, but doesn't quite get what I want. Then I have what I think should be the adjustment but it is not working.

Working (but not quite there):
Code:
[FONT=Arial][SIZE=2][COLOR=#000000] .PrintArea = "$B$4:" & _
        Cells(7 + Vendor_Count, 3 + SQC_Count).Address & _
        "," & _
        Cells(9 + Vendor_Count, 2).Address & _
        ":" & _
        Cells((15 + Vendor_Count + Range("b" & (11 + Vendor_Count)).Value), 8 + Metric_Count).Address[/COLOR][/SIZE][/FONT]

</pre>

That renders a print area of, say, "B4:F12, B15:BE21", which is good, except for one thing: that BE21 is static. What I need for the very end to be able to do is adjust based on the amount of data entered. I have always used an INDIRECT function to do this with success. The problem, this time, is that I don't want the column letter in the Indirect to be static either (it should be adjusted). Here's what I've tried:

Code:
.PrintArea = "$B$4:" & Cells(7 + Vendor_Count, 3 + SQC_Count).Address & _
 "," & _
Cells(9 + Vendor_Count, 2).Address & _
":Indirect($c$3&($d$3+$e$3))"

This renders a print area of "B4:BE15". I don't know why. It ignores the comma and the indirect does not stay in. I'd want the finished product to look like this:
"B4:F12, B15:Indirect(c3 & (d3 + e3))"

I would have c3 set as a column letter and d3 and e3 set as numbers based on Vendor_Count and then a count of the lines of data in the table.

Convoluted, I know, but I'm hoping someone can help!

Thank you!
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Is this question just too complicated and ridiculous? Unfortunately, I cannot attach a sample workbook for example purposes...
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,345
Members
452,907
Latest member
Roland Deschain

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top