+ Reply to Thread
Results 1 to 2 of 2

Macro help in copying data from multiple sheets to first Sheet of workbook based on condn

Hybrid View

  1. #1
    Registered User
    Join Date
    07-26-2012
    Location
    india
    MS-Off Ver
    Excel 2003
    Posts
    13

    Macro help in copying data from multiple sheets to first Sheet of workbook based on condn

    Hi,

    I wanted to copy data from multiple sheets to first sheet (master) if value in column D is found as "Arc" (suppose).
    I don't want to hard code this value instead wanted to use input box.

    Any help appreciated. As i am new to VBA.


    I tried something but seems there is some issue. Below is my code which i tried. Please help me to solve the issue.
    Sub CombineData()
    Dim Sht As Worksheet
    Dim strToFind As String, FirstAddress As String
    For Each Sht In ActiveWorkbook.Worksheets
    If Sht.Name <> "master" Then
    Sht.Select
    Application.ScreenUpdating = False

    strToFind = InputBox("Enter the Action Item On")
    For r = 1 To 5
    With ActiveSheet.Range("A1:AY23331")
    Set rngC = .Find(what:=strToFind, LookAt:=xlPart)
    If Not rngC Is Nothing Then
    FirstAddress = rngC.Address
    Do
    strLastRow = Worksheets("master").Range("A" & Rows.Count).End(xlUp).Row + 1

    rngC.EntireRow.Copy wSht.Cells(strLastRow, 1)
    Set rngC = .FindNext(rngC)
    Loop While Not rngC Is Nothing And rngC.Address <> FirstAddress

    End If
    End With
    Next r
    End If
    Next Sht
    End Sub

    Regards,
    Archies

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,026

    Re: Macro help in copying data from multiple sheets to first Sheet of workbook based on co

    Try:
    Sub CopyRows()
        Application.ScreenUpdating = False
        Dim bottomD As Integer
        Dim ws As Worksheet
        Dim rng As Range
        Dim strToFind As String
        strToFind = InputBox("Enter the Action Item On")
        For Each ws In Sheets
            If ws.Name <> "Master" Then
                ws.Activate
                bottomD = Range("D" & Rows.Count).End(xlUp).Row
                For Each rng In Range("D2:D" & bottomD)
                    If rng = strToFind Then
                        rng.EntireRow.Copy Sheets("Master").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
                    End If
                Next rng
            End If
        Next ws
        Application.ScreenUpdating = True
    End Sub

+ 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: 0
    Last Post: 03-27-2012, 04:54 PM
  2. Copying a template sheet and putting those multiple sheets data into a summary sheet
    By John Wolfe in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-18-2011, 06:29 PM
  3. copying data from sheets in workbook to summary sheet in same
    By Nets in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-19-2009, 03:49 PM
  4. Copying data from workbook/sheets to another workbook/sheet
    By yukon_phil in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-26-2006, 02:35 PM
  5. Copying data from multiple sheets into one sheet
    By Todd in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-13-2005, 11:05 PM

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