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

lunatu

Board Regular
Joined
Feb 5, 2021
Messages
62
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

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
67,938
Office Version
  1. 365
Platform
  1. Windows
What is the value in Col I that determines if the row should be copied?
 

lunatu

Board Regular
Joined
Feb 5, 2021
Messages
62
Office Version
  1. 2010
Platform
  1. Windows
  2. Web
It is text "Sold" in column I so all the rows with status "Sold" should be copied into the specific employees sheet.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
67,938
Office Version
  1. 365
Platform
  1. Windows
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
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
67,938
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,151,770
Messages
5,766,379
Members
425,350
Latest member
procha

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
Top