Results 1 to 5 of 5

Copy data across multiple worksheets (based on three criteria)

Threaded 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

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