+ Reply to Thread
Results 1 to 2 of 2

Summary Sheet based on selected date

Hybrid View

  1. #1
    Registered User
    Join Date
    01-06-2014
    Location
    Pannawonica, Western Australia
    MS-Off Ver
    Excel 2003
    Posts
    1

    Summary Sheet based on selected date

    Hello,

    I am looking for a way to coalate certain data from all worksheets in my workbook in one summary sheet based on a user inputted date.

    The workbook will grow with additional sheets added at irregular intervals.
    Each worksheet has the same layout, just with different data.
    I want a user to input a date in cell B2.
    Then i want the vba to look that value up in all other sheets and copy data from adjacent cells.

    I have attached a sample workbook.

    Thanks in advance for any help you may be able to provide.

    PaulineProject Plans - Sample.xlsm

  2. #2
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Summary Sheet based on selected date

    Hi,

    You can try this code :

    Sub GetData()
      Dim strSearch As String, sh As Worksheet, rng As Range, cell As Range
      Dim i As Long, mtx(), ptrMtx As Long
    
      Sheets("Summary").Select
      strSearch = Format(Range("B2").Value, "DD, MMM")
      ReDim mtx(1 To 3, 1 To 1000)
      ptrMtx = 0
    
      For Each sh In Worksheets
          If sh.Index <> ActiveSheet.Index Then
             With sh
               Set cell = .Cells.Find(strSearch, LookIn:=xlValues, lookat:=xlPart)
               If Not cell Is Nothing Then
                  Set rng = .Range(cell.Offset(1), .Cells(.Rows.Count, cell.Column).End(xlUp))
                  For i = 1 To rng.Rows.Count
                      If (.Cells(rng.Row + i - 1, "B") = "Trade:") And (rng.Cells(i, 1) <> "") Then
                         ptrMtx = ptrMtx + 1
                         mtx(1, ptrMtx) = rng.Cells(i, 1)
                         mtx(2, ptrMtx) = rng.Cells(i + 1, 1)
                         mtx(3, ptrMtx) = rng.Cells(i + 3, 1)
                         i = i + 4
                      End If
                  Next i
               End If
             End With
          End If
      Next sh
    
      Range("C3:E" & Rows.Count).ClearContents
      If ptrMtx = 0 Then
         MsgBox "Nothing found"
         Exit Sub
      Else
         ReDim Preserve mtx(1 To 3, 1 To ptrMtx)
         Range("C3").Resize(UBound(mtx, 2), UBound(mtx, 1)).Value = Application.WorksheetFunction.Transpose(mtx)
      End If
    End Sub
    Regards
    1. I care dog
    2. I am a loop maniac
    3. Forum rules link : Click here
    3.33. Don't forget to mark the thread as solved, this is important

+ 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. Replies: 2
    Last Post: 01-28-2014, 08:41 AM
  2. Replies: 0
    Last Post: 06-27-2013, 07:04 AM
  3. Monthly spreadsheet- need to update summary sheet based on date
    By hootiebsc in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 03-08-2013, 02:17 PM
  4. Creating a summary sheet based on date and printing it
    By bchico in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-20-2012, 11:50 AM
  5. Recording Data in Summary sheet based on date and site.
    By ddthomps in forum Excel General
    Replies: 0
    Last Post: 07-18-2012, 12:31 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