this macro works perfect, but does not finish creating??
If a c is in col O macro should create a new sheet.
If P is col O it prints.
The only problem is when I try to create a big list. It doesn't finish.
Any Ideas.
this macro works perfect, but does not finish creating??
If a c is in col O macro should create a new sheet.
If P is col O it prints.
The only problem is when I try to create a big list. It doesn't finish.
Any Ideas.
Hello erock24,
How big of list are you referring to? What error message and number to you get or does the program freeze?
Thanks,
Leith Ross
See if this works for you:![]()
''''''''''''''''''''''''''''''''''''''''''''''''' ' REMOVE THIS ' ''''''''''''''''''''''''''''''''''''''''''''''''' ' ' 'With InvSht ' ' .Cells(1, 14).Value = c.Value ' ' .Copy after:=Worksheets(Worksheets.Count) ' 'End With ' 'On Error Resume Next ' ''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' ADD THIS ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' ' ActiveWorkbook.Worksheets.Add after:=Worksheets(Sheets.Count) ' InvSht.Cells(1, 14).Value = c.Value ' InvSht.Cells.Copy ' ActiveSheet.Range("A1").PasteSpecial ' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
I edited code with your change, it works but I loose my print options.
I need to have those new sheets print to 1 page.
I added code I thought would do it but it doesn't. What have I done wrong??
![]()
With Main Set rng = .Range(.Cells(12, 2), .Cells(.Rows.Count, 2).End(xlUp)) For Each c In rng R = c.Row If .Cells(R, 12).Value = 1 And .Cells(R, 15) = "C" Then ActiveWorkbook.Worksheets.Add after:=Worksheets(Sheets.Count) InvSht.Cells(1, 14).Value = c.Value InvSht.Cells.Copy ActiveSheet.Range("A1").PasteSpecial On Error Resume Next ActiveSheet.Name = Cells(7, 9).Value ActiveSheet.UsedRange.Value = ActiveSheet.UsedRange.Value ActiveSheet.PageSetup.PrintArea = "$B$2:$I$46" ActiveSheet.PageSetup.FitToPagesWide = 1 ActiveSheet.PageSetup.FitToPagesTall = 1 Application.CutCopyMode = False intPrintCounter = intPrintCounter + 1 End If Next c End With
It doesn't freeze it just doesn't produce all the sheets it should.How big of list are you referring to? What error message and number to you get or does the program freeze?
Ikaabod's edit fixed that problem, but now I have a print set up issue. i guess since the copy method is different. I don't really know why Ikaabod's edit works.
Excel (2003) seems to not like copying an entire sheet to the end of a workbook with "x" amount of worksheets (somewhere around 40). I tried doing this manually and it still wasn't allowing me to.
To avoid that I changed the code so it creates a new worksheet, then copy/paste's the template invoice into the newly created sheet and rename's the worksheet.
I can take a look at the printing problem.
EDIT: Try this![]()
With Main Set rng = .Range(.Cells(12, 2), .Cells(.Rows.Count, 2).End(xlUp)) For Each c In rng R = c.Row If .Cells(R, 12).Value = 1 And .Cells(R, 15) = "C" Then ActiveWorkbook.Worksheets.Add after:=Worksheets(Sheets.Count) InvSht.Cells(1, 14).Value = c.Value InvSht.Cells.Copy With ActiveSheet .Range("A1").PasteSpecial On Error Resume Next .Name = Cells(7, 9).Value .UsedRange.Value = ActiveSheet.UsedRange.Value .PageSetup.PrintArea = "$B$2:$I$46" .PageSetup.Zoom = False '<--------------------ADDED .PageSetup.FitToPagesWide = 1 .PageSetup.FitToPagesTall = 1 End With Application.CutCopyMode = False intPrintCounter = intPrintCounter + 1 End If Next c End With
Last edited by Ikaabod; 11-29-2007 at 05:56 PM. Reason: Added code for printing to one page
And that's amazing.
Works perfectly Thank you very much for your time and help.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks