I want to write vba code for setting print area. first page is introduction (A1:Q53) and from A54 onwards i want to print upto end of data. kindly suggest the command. there are empty cells on first page hence if i give command to search end of data it stops at first page itself.
Asked
Active
Viewed 564 times
-1
-
Try recording a macro while you perform the actions manually. When you are done, look at the code with a mind to changing the `.Select` references to direct cell and worksheet references. See [How to avoid using Select in Excel VBA macros](http://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba-macros) for hints on this. If you run into trouble, come back and edit your question to include your own efforts and we can try to help. – May 13 '15 at 05:35
1 Answers
0
Even though your question is not completely clear, I would suggest using either CurrentRegion of the Range A54 or resolve the range you need using the UsedRange property of the sheet.

Tom
- 747
- 5
- 16
-
the data after A53:Q is dynamic. if i program to print till data is present in C column; due to presence of empty cells in first page it doesnot print the second page – KETAKI May 12 '15 at 11:54
-
I think you may need to use UsedRange. This gives you the complete range of cells that contain any data in the given sheet (sadly also cells that are only formatted, so you may get a little more than you planned) Something like this may do the trick Sheet1.UsedRange.Offset(RowOffset := 54).Resize(RowSize:=Sheet1.UsedRange.Rows.Count - 54) – Tom May 12 '15 at 12:13