+ Reply to Thread
Results 1 to 6 of 6

Search mutli sheets and capture

  1. #1
    Registered User
    Join Date
    03-30-2014
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    63

    Red face Search mutli sheets and capture

    Hi There All Gurus

    I need Help - I have created a mess and had to start from scratch and need your help.

    I have to assemble a Asset Register per Department with the last service date and the Next service date. I want to create a VBA to search all the sheets (Tabs) and retrieve all the equipment which has to be serviced on the month I select in the "Monthly service" Tab.

    Please see the attachment.

    I hope someone can help me

    Much appreciated
    Attached Files Attached Files
    Last edited by ronettes; 08-29-2018 at 10:29 AM.

  2. #2
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,785

    Re: Search mutli sheets and capture

    Try this

    PHP Code: 
    Sub summary()
        
    Dim MonthRng As Range
        Dim i 
    As Integer
        Dim sh 
    As Worksheet
        Dim M 
    As String
        Dim shMonthly 
    As Worksheet
        
        Set shMonthly 
    Sheets(1)
        
    Set MonthRng Sheet2.Range("A2:A13").Find(CStr(shMonthly.Range("C1").Value), , xlValuesxlWhole)
        For 
    Each sh In ThisWorkbook.Worksheets
            
            
    If sh.Name <> "Monthly Service" And sh.Name <> "CONDITIONS" Then
                
    For 3 To sh.Range("A" Rows.Count).End(xlUp).Row
                    M 
    Val(MonthRng.Offset(, 1).Value)
                    If 
    Month(sh.Range("H" i).Value) = M Then
                        With shMonthly
                            
    .Range("B" & .Range("B" Rows.Count).End(xlUp).Offset(10).Row).Value sh.Range("I" i).Value
                            
    .Range("C" & .Range("C" Rows.Count).End(xlUp).Offset(10).Row).Value sh.Range("B1").Value
                            
    .Range("D" & .Range("D" Rows.Count).End(xlUp).Offset(10).Row).Value sh.Range("C" i).Value
                            
    .Range("E" & .Range("E" Rows.Count).End(xlUp).Offset(10).Row).Value sh.Range("A" i).Value
                        End With
                    End 
    If
                
    Next i
                End 
    If
        
    Next sh
    End Sub 
    Teach me Excel VBA

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,688

    Re: Search mutli sheets and capture

    In the worksheet "Monthly Service", change C1 to a number, ie. Jan would be 1, Feb would be 2, etc. Then apply this code

    Please Login or Register  to view this content.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  4. #4
    Registered User
    Join Date
    03-30-2014
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    63

    Re: Search mutli sheets and capture

    Quote Originally Posted by ImranBhatti View Post
    Try this

    PHP Code: 
    Sub summary()
        
    Dim MonthRng As Range
        Dim i 
    As Integer
        Dim sh 
    As Worksheet
        Dim M 
    As String
        Dim shMonthly 
    As Worksheet
        
        Set shMonthly 
    Sheets(1)
        
    Set MonthRng Sheet2.Range("A2:A13").Find(CStr(shMonthly.Range("C1").Value), , xlValuesxlWhole)
        For 
    Each sh In ThisWorkbook.Worksheets
            
            
    If sh.Name <> "Monthly Service" And sh.Name <> "CONDITIONS" Then
                
    For 3 To sh.Range("A" Rows.Count).End(xlUp).Row
                    M 
    Val(MonthRng.Offset(, 1).Value)
                    If 
    Month(sh.Range("H" i).Value) = M Then
                        With shMonthly
                            
    .Range("B" & .Range("B" Rows.Count).End(xlUp).Offset(10).Row).Value sh.Range("I" i).Value
                            
    .Range("C" & .Range("C" Rows.Count).End(xlUp).Offset(10).Row).Value sh.Range("B1").Value
                            
    .Range("D" & .Range("D" Rows.Count).End(xlUp).Offset(10).Row).Value sh.Range("C" i).Value
                            
    .Range("E" & .Range("E" Rows.Count).End(xlUp).Offset(10).Row).Value sh.Range("A" i).Value
                        End With
                    End 
    If
                
    Next i
                End 
    If
        
    Next sh
    End Sub 
    Hi ImranBhatti

    Should I paste this in a Button, or just on the page under General?

    Thank you so much

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,688

    Re: Search mutli sheets and capture

    How to install your new code
    1. Copy the Excel VBA code
    2. Select the workbook in which you want to store the Excel VBA code
    3. Press Alt+F11 to open the Visual Basic Editor
    4. Choose Insert > Module
    5. Edit > Paste the macro into the module that appeared
    6. Close the VBEditor
    7. Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)

    To run the Excel VBA code:
    1. Press Alt-F8 to open the macro list
    2. Select a macro in the list
    3. Click the Run button

  6. #6
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,785

    Re: Search mutli sheets and capture

    Quote Originally Posted by ronettes View Post
    Hi ImranBhatti

    Should I paste this in a Button, or just on the page under General?

    Thank you so much

    You have created a button "BUTTON: UPDATE SERVICE???" . The code linked to that button.
    Attached Files Attached Files
    Last edited by ImranBhatti; 08-29-2018 at 09:37 AM. Reason: Attachment left

+ 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. Search range for date, then capture details
    By ks100 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-15-2015, 12:16 PM
  2. Macro to Automate Web Search and Capture Screenshots
    By HardHitter in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-27-2014, 10:21 AM
  3. Mutli-year graph by month
    By Nelssie in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 06-26-2014, 09:57 AM
  4. Conditional Formating mutli CountIf
    By johnny_p in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-15-2013, 12:15 PM
  5. Mutli-column Formula
    By btwc in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-21-2013, 05:46 PM
  6. Clearer way to do Mutli-replace?
    By TheDPQ in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-04-2010, 09:39 PM
  7. Mutli-user form access
    By joenewman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-27-2009, 03:35 AM

Tags for this Thread

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