Loop Diffrent Excel Sheet and paste data in Master Sheet in lastrow

ajkua

New Member
Joined
Dec 22, 2015
Messages
5
Hi Everyone,

I need some code that will Copy Diffrent Excel Files data and paste into Master file

Simply stated, the loop code will open every file in a single directory and, one at a time, will copy/paste to the Master.

What I need is the loop code to go through all of the Excel files Remove Filter Unhide All Cell and stop when the process has been performed on the last file.

Been searching the web, but not able to find suitable code I need the VBA Code Of this

I'm running Excel 2007,
Thanks in Advance
Ajay
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Dude,
I have a Macro that does exactly wht you're asking, but I do not have the time to remove the personalized settings since I'm at work right now. But... this will give a good starting point.
I believe you would need to change the 'Make_me_Work' Function.
Code:
Sub LoopThroughFiles()
Application.ScreenUpdating = False
    Dim StrFile As String
    Set TB = ThisWorkbook
    On Error GoTo GetOut
    Call clear
    StrFile = Dir(ThisWorkbook.Path & "\Raw Data\" & "filename*")
    Do While Len(StrFile) > 0
        Debug.Print StrFile
        StrFile = Dir
        Workbooks.Open Filename:=ThisWorkbook.Path & "\Raw Data\" & StrFile
        Make_me_Work
    Loop
GetOut:
Application.ScreenUpdating = True
End Sub
' ***********************************
Function Make_me_Work()
  Dim FindString As String
  Dim MyDate
  Set wb2 = ActiveWorkbook
    Dim Rng As Range
    FindString = "Agent ID"
    If Trim(FindString) <> "" Then
        With Range("A:A")
            Set Rng = .Find(What:=FindString, _
                            After:=.Cells(.Cells.Count), _
                            LookIn:=xlValues, _
                            LookAt:=xlWhole, _
                            SearchOrder:=xlByRows, _
                            SearchDirection:=xlNext, _
                            MatchCase:=False)
            If Not Rng Is Nothing Then
                'Application.Goto Rng, True
                Rng.Offset(1, 0).Select
                Let MyDate = ActiveCell.Offset(-3, 1).Value
                ActiveSheet.Range(ActiveCell, ActiveCell.Offset(0, 13).End(xlDown)).Select
                Selection.Copy
                TB.Activate
                Sheets("Top Agent").Activate
                Range("C69").End(xlUp).Offset(1, 0).Select
                ActiveSheet.Paste
                Application.CutCopyMode = False
                     Do Until IsEmpty(ActiveCell)
                       ActiveCell.Offset(0, -1).Value = MyDate
                       ActiveCell.Offset(1, 0).Select
                    Loop
                    
            Else
                MsgBox "Nothing found"
            End If
        End With
    End If
   wb2.Activate
   ActiveWorkbook.Close
End Function
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top