VBA Print worksheets from List Objects

BODYCOTE

New Member
Joined
May 18, 2021
Messages
21
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I had previously been printing multiple worksheets from 1 table using the following code

VBA Code:
Sub PrintRecipes()
 Dim c As Range, LR As Long, lo As ListObject
 Set lo = Sheets("****tail Conversion Sheet").ListObjects(1)
  With ActiveSheet
   On Error Resume Next
   .ShowAllData
   On Error GoTo 0
   .PrintOut
   LR = .Cells(Rows.Count, 5).End(3).Row
   If Application.CountIf(.Range("E4:E" & LR), ">0") > 0 Then
   .Range("B3:G" & LR).AutoFilter 4, ">" & 0
    For Each c In .Range("B4:B" & LR).SpecialCells(12)
     Sheets(c.Value).PrintOut
    Next c
    lo.AutoFilter.ShowAllData
   End If
  End With
  Sheets("****tail Conversion Sheet").Select
End Sub

However i have just split the table/List Object into 2 tables on the same worksheet, how can i adapt this VBA to print the first and second table.

1641963673016.png
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Sheets(c.Value).PrintOut
one of this options ?
VBA Code:
     With Sheets(c.Value)
          .PageSetup.PrintArea = "$a$1:$d$100"                  'the address that includes both listobjects
          .PrintPreview                                         'later printout instead of printpreview
     End With

     Sheets(c.Value).Range("A1:Z4").PrintPreview                'later printout instead of printpreview
 
Upvote 0

Forum statistics

Threads
1,214,584
Messages
6,120,387
Members
448,957
Latest member
Hat4Life

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