i tried running this code and its fine in so long as i am on that worksheet but i want to be to have this executed without actually printing a page, since i am doing the emailing thing, - so i want to execute it so it will either display two pages or one depending on the data entered, and thereby printing the last row. but cant figure out how to have it done in a macro without having it not actually printout the page, just want it to calculate, so when i do create a pdf from email it will show the results, does that make sense...
Application.ScreenUpdating = False
Sheets("BillBack").Visible = True
Dim lastRow1 As Long, i As Long
For i = 3 To 67
If Len(Trim(Cells(i, "S").Value)) > 0 Then
lastRow1 = i
ActiveSheet.PageSetup.PrintArea = "C2:S" & lastRow1
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Worksheets("BillBack").Visible = xlSheetVeryHidden
Application.ScreenUpdating = True
If you generate a PDF, it should be the same whether you have printed the sheet or you haven't as long as printing the sheet doesn't establish new formatting (in other words if you have a beforeprint event that changes the footer or something than that routine would need to be run to format the footer).
so what you say doesn't make much sense to me. Try formatting the sheet as you want to see it and then run you code without printing the sheet. I would expect it to be formatted as it would have looked if it were printed with just the existing formatting.
But again, tha tis only a guess on my part.
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here