+ Reply to Thread
Results 1 to 5 of 5

Copy data across multiple worksheets (based on three criteria)

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    10-28-2009
    Location
    Portland, Maine
    MS-Off Ver
    Excel 2003
    Posts
    102

    Copy data across multiple worksheets (based on three criteria)

    I have data on a worksheet (“Interface”) that I need to copy over 7 other tabs for analysis ("Module_1", "Module_2", "Module_3", "Module_4", "Module_5", "Module_6", "Module_7").

    The linking Field on the Interface tab defines what row I need to paste the data to on Module 1-7.

    The column headers are the same on both the interface and other tabs (“YES, NO, N/A, BLANKS, STANDARDS MET, STANDARDS NOT MET, NOT APPLICABLE”)

    The tab is selected based on the row
    Module 1 Medication Management
    Module 2 Privacy
    Module 3 Process
    Module 4 Patient Safety
    Module 5 Medical Records
    Module 6 Infection Control
    Module 7 Environment of Care

    I’m trying to modify code written for a similar purpose with no luck. This is the code I'm trying to modify. I know I'm not on the right track yet. But this was the general idea I was going for...

    Sub Log_Data()
      Dim DateRng As Range
      Dim DstWks As Worksheet
      Dim Facility As String
      Dim I As Integer
      Dim LastEntry As Range
      Dim RawRng As Range
      Dim shtArray As Variant
      Dim SrcWks As Worksheet
      
        shtArray = Array("Module_1", "Module_2", "Module_3", "Module_4", _
                         "Module_5", "Module_6", "Module_7")
                         
        Set SrcWks = Worksheets("INTERFACE")
        Facility = SrcWks.Range("C1")
        
        Set LastEntry = SrcWks.Cells.Find("*", , xlValues, xlWhole, xlByRows, xlPrevious, False)
          If Not LastEntry Is Nothing Then
             If LastEntry.Address = "$A$12" Then Exit Sub
             Set RawRng = LastEntry.Offset(-6, 0).Resize(7, 1)
             EntryDate = LastEntry.Offset(-7, 0).Text
          End If
          
          For I = 0 To UBound(shtArray)
            Set DstWks = ThisWorkbook.Worksheets(shtArray(I))
               Set DateRng = DstWks.Rows(1).Find(EntryDate, , xlValues, xlWhole, xlByColumns, xlPrevious, False)
               Set FacRng = DstWks.Columns(1).Find(Facility, , xlValues, xlWhole, xlByRows, False)
               If Not DateRng Is Nothing And Not FacRng Is Nothing Then
                  DstWks.Cells(FacRng.Row, DateRng.Column) = RawRng.Cells(I + 1, 1)
               End If
          Next I
    
    End Sub
    Any help would be much appreciated.
    Thanks!
    Mike
    Attached Files Attached Files
    Last edited by yunesm; 02-16-2010 at 04:47 PM. Reason: Solved

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Copy data across multiple worksheets (based on three criteria)

    Try this instead:
    Option Explicit
    
    Sub ParseData()
    'JBeaucaire  2/16/2010
    Dim LR As Long, i As Long, r As Long
    Dim LField As String, ws As String
    
    With Sheets("INTERFACE")
        LField = .[C1].Text
        LR = .Range("A" & Rows.Count).End(xlUp).Row
        For i = 5 To LR
            .[D1].FormulaR1C1 = "=MATCH(RC3,'" & Cells(i, "A") & "'!C1,0)"
            r = .[D1].Value
            ws = Cells(i, "A").Text
            .Range(Cells(i, "C"), Cells(i, "I")).Copy
            Sheets(ws).Range("B" & r).PasteSpecial xlPasteValuesAndNumberFormats
        Next i
        
        .[D1] = ""
    End With
            
    End Sub
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Contributor
    Join Date
    10-28-2009
    Location
    Portland, Maine
    MS-Off Ver
    Excel 2003
    Posts
    102

    Re: Copy data across multiple worksheets (based on three criteria)

    Thanks you! It works great. I appreciate the help.
    Thanks,
    Mike

  4. #4
    Registered User
    Join Date
    10-16-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Copy data across multiple worksheets (based on three criteria)

    I am attempting to consolidate multiple sheets of text data within the same workbook into a master sheet within the same workbook, automatically. The master sheet is to only pull in those rows that have "false" marked in column D (or have the check box depressed) and I would like to have this happen real time. All of the headers are the same, however the data on each tab is different. I have columns A-J and infinite rows.
    I am more of a novice at macros, so I would need something I could copy paste. Any help would be great.

  5. #5
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,684

    Re: Copy data across multiple worksheets (based on three criteria)

    Welcome to the Forum tbrice,, unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.
    Ben Van Johnson

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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