Copy specific rows from sheet to another when there is multiple sheets

lunatu

Board Regular
Joined
Feb 5, 2021
Messages
77
Office Version
  1. 2010
Platform
  1. Windows
  2. Web
Hi, could some one help me with this...

Im having an Excel where there is one "Main" sheet where all the data is. Based on the value on column I specific cells (A, B, C, E, F, J, K L) are copied automatically into another sheet. There are multiple sheets (all named by employee name) and the macro should recognize in which sheet the rows should be copied based on "Main" sheets column J (employees name in this column, same as there is in sheets).

Is this possible to solve?
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
What is the value in Col I that determines if the row should be copied?
 
Upvote 0
It is text "Sold" in column I so all the rows with status "Sold" should be copied into the specific employees sheet.
 
Upvote 0
Ok, how about
VBA Code:
Sub lunatu()
   Dim Cl As Range
   Dim Dic As Object
   Dim i As Long
   
   Application.ScreenUpdating = False
   Set Dic = CreateObject("scripting.dictionary")
   With Sheets("Main")
      For Each Cl In .Range("J2", .Range("J" & Rows.Count).End(xlUp))
         Dic(Cl.Value) = Empty
      Next Cl
      For i = 0 To Dic.Count - 1
         .Range("A1:L1").AutoFilter 9, "Sold"
         .Range("A1:N1").AutoFilter 10, Dic.Keys()(i)
         If Evaluate("isref('" & Dic.Keys()(i) & "'!A1)") Then
            Intersect(.AutoFilter.Range.Offset(1).EntireRow, .Range("A:C,E:F,J:L")).Copy Sheets(Dic.Keys()(i)).Range("F" & Rows.Count).End(xlUp).Offset(1, -5)
         End If
      Next i
      .AutoFilterMode = False
   End With
End Sub
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,488
Members
448,967
Latest member
visheshkotha

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