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

#### lunatu

##### Board Regular
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
What is the value in Col I that determines if the row should be copied?

#### lunatu

##### Board Regular
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
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``````

Great thanks!

#### Fluff

##### MrExcel MVP, Moderator
You're welcome & thanks for the feedback.

Replies
1
Views
162
Replies
3
Views
148
Replies
0
Views
154
Replies
0
Views
388
Replies
3
Views
146

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.

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.

### Which adblocker are you using?

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

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