+ Reply to Thread
Results 1 to 8 of 8

Create and print report from across multiple worksheets based on cell values

Hybrid View

  1. #1
    Registered User
    Join Date
    03-27-2016
    Location
    Akansas
    MS-Off Ver
    2013
    Posts
    13

    Create and print report from across multiple worksheets based on cell values

    I have created a Macros enabled workbook with multiple worksheets they all have the same column structure but on certain pages some columns are hidin. what i am trying to do is on my report sheet i am wanting to select a Field supervisor and be able to create a report for that field supervisor and print it off showing all jobs and the status of each job that is assigned to them.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: Create and print report from across multiple worksheets based on cell values

    See attached file, I hope that it's what you need.

    This is the code that I used:
    Private Sub Worksheet_Change(ByVal Target As Range)
       If Target.Cells.Count = 1 Then
          If Target.Address(0, 0) = "B8" Then
             Call refreshReport
          End If
       End If
    End Sub
    Private Sub refreshReport()
       Dim myRange As Range, mySh As Worksheet
       Dim lastRow As Long, destRow As Long, r As Long
       Dim visibleRows As Long, c As Integer
       
       Application.EnableEvents = False
       Application.ScreenUpdating = False
       
       destRow = 10
       With ThisWorkbook.Sheets("reports")
          .Range("11:" & Rows.Count).ClearContents
          For Each mySh In ThisWorkbook.Sheets
             If LCase(mySh.Name) <> "main" _
                And LCase(mySh.Name) <> "reports" _
                And LCase(mySh.Name) <> "info" Then
                mySh.AutoFilterMode = False
                lastRow = mySh.Cells(1, 5).CurrentRegion.Rows.Count
       
                For r = 6 To lastRow
                   If mySh.Cells(r, 1) = .Range("b8") Then
                      destRow = destRow + 1
                      .Range("a" & destRow & ":l" & destRow).Value = mySh.Range("b" & r & ":m" & r).Value
                   End If
                Next r
                If destRow > 11 Then
                   Range("A11:N11").Copy
                   Range("A12:N" & destRow).PasteSpecial Paste:=xlPasteFormats
                   Application.CutCopyMode = False
                   .Range("a11").Activate
                End If
             End If
          Next mySh
       End With
       Application.EnableEvents = True
       Application.ScreenUpdating = True
    End Sub
    Regards,
    Antonio
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    03-27-2016
    Location
    Akansas
    MS-Off Ver
    2013
    Posts
    13

    Re: Create and print report from across multiple worksheets based on cell values

    Ok i have copied and pasted the VBA to my main sheet and it is only pulling the information for three of the five in B8 and i only need it to pull information from the following tabs: Ready, Scheduled, InProgress, OnHold, CTL and Complete. Other than that this is just what i was wanting to do... Thanks for the help
    Last edited by stkachuk07; 10-11-2016 at 10:07 AM.

  4. #4
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: Create and print report from across multiple worksheets based on cell values

    Try with this new code. You don't find 'Mike Oliver ' because in Info sheet there is a blank at the end of the name, and you don't find 'HARRY BURKHART' because in Info sheet it's writtend without 'D' and in the sheets is written 'HARRY BURKHARDT'.
    Private Sub Worksheet_Change(ByVal Target As Range)
       If Target.Cells.Count = 1 Then
          If Target.Address(0, 0) = "B8" Then
             Call refreshReport
          End If
       End If
    End Sub
    Private Sub refreshReport()
       Dim myRange As Range, mySh As Worksheet
       Dim lastRow As Long, destRow As Long, r As Long
       Dim visibleRows As Long, c As Integer
       
       Application.EnableEvents = False
       Application.ScreenUpdating = False
       
       destRow = 10
       With ThisWorkbook.Sheets("reports")
          .Range("11:" & Rows.Count).ClearContents
          For Each mySh In ThisWorkbook.Sheets
             If InStr("ready,scheduled,inprogress,onhold,ctl,complete", LCase(mySh.Name)) > 0 Then
                mySh.AutoFilterMode = False
                lastRow = mySh.Cells(1, 5).CurrentRegion.Rows.Count
       
                For r = 6 To lastRow
                   If mySh.Cells(r, 1) = .Range("b8") Then
                      destRow = destRow + 1
                      .Range("a" & destRow & ":l" & destRow).Value = mySh.Range("b" & r & ":m" & r).Value
                   End If
                Next r
                If destRow > 11 Then
                   Range("A11:N11").Copy
                   Range("A12:N" & destRow).PasteSpecial Paste:=xlPasteFormats
                   Application.CutCopyMode = False
                   .Range("a11").Activate
                End If
             End If
          Next mySh
       End With
       Application.EnableEvents = True
       Application.ScreenUpdating = True
    End Sub
    Regards,
    Antonio

  5. #5
    Registered User
    Join Date
    03-27-2016
    Location
    Akansas
    MS-Off Ver
    2013
    Posts
    13

    Re: Create and print report from across multiple worksheets based on cell values

    Antonio,
    Thanks for you help this is just what I was looking for

  6. #6
    Registered User
    Join Date
    03-27-2016
    Location
    Akansas
    MS-Off Ver
    2013
    Posts
    13

    Re: Create and print report from across multiple worksheets based on cell values

    now i got to figure out how to convert the workbook it so i can use it on Google sheets

  7. #7
    Registered User
    Join Date
    03-27-2016
    Location
    Akansas
    MS-Off Ver
    2013
    Posts
    13
    Antonio,
    this works great but i have one more piece of the puzzle i need help with. on my report sheet i would also like to print out reports for who ever the jobs are issued to as well so i can filter either by field supervisor or by the issued to column. can you help with that ?

  8. #8
    Registered User
    Join Date
    03-27-2016
    Location
    Akansas
    MS-Off Ver
    2013
    Posts
    13
    OK someting has went array with my VBA Code it is not pulling every column from pages in the report what have i done lol

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Using VBA to create a table based on values on multiple worksheets
    By JoelG in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-07-2015, 08:58 AM
  2. Replies: 8
    Last Post: 06-24-2014, 03:35 PM
  3. Replies: 5
    Last Post: 03-01-2014, 07:41 PM
  4. (Likely VBA) - Need to create multiple values Based on One cell's value
    By nobody2000 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-29-2012, 12:41 PM
  5. print a report based on cell value
    By excelluni in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-27-2009, 07:57 AM
  6. Create Worksheets Based on Cell Values
    By modytrane in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-28-2008, 04:55 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1