Copy Data To Sheet Name That Matches Values

benntw

Board Regular
Joined
Feb 17, 2014
Messages
222
Office Version
  1. 365
Platform
  1. Windows
I have a spreadsheet that has data from A3 to J3. Starting on H3 I have values that are the same as my sheet names. I'd like to copy all the values to each sheet from the match in column H. Can anyone help with this ? On each sheet the name is also in A1. The headers match on each sheet to the main sheet. Thanks for the help.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
VBA Code:
Sub t()
Dim sh As Worksheet, c As Range
Set sh = ActiveSheet 'Assumes main sheet is the active sheet.
    With sh
        For Each c In .Range("H3", .Cells(Rows.Count, 8).End(xlUp))
            c.EntireRow.Copy Sheets(c.Value).Cells(Rows.Count, 1).End(xlUp)(2)
        Next
    End With
End Sub
 
Upvote 0
Appreciate the help. I think my data is too large. It is locking up my workbook. Right now I have 16 sheet names to copy data to. I will end up having 30 sheet names when I am done.
 
Upvote 0
Try this version and see if it still locks up.

VBA Code:
Sub t2()
Dim sh As Worksheet, c As Range
Set sh = ActiveSheet 'Assumes main sheet is the active sheet.
    With sh
        .Range("H2", .Cells(Rows.Count, 8).End(xlUp)).AdvancedFilter xlFilterCopy, , .Cells(Rows.Count, 1).End(xlUp)(3), True
        For Each c In .Cells(Rows.Count, 1).End(xlUp).CurrentRegion.Offset(1)
            If c <> "" Then
                .UsedRange.AutoFilter 8, c.Value
                .Range("H3", .Cells(Rows.Count, 8).End(xlUp)).SpecialCells(xlCellTypeVisible).EntireRow.Copy Sheets(c.Value). _
                Cells(Rows.Count, 1).End(xlUp)(2)
                .AutoFilterMode = False
            End If
        Next
        .Cells(Rows.Count, 1).End(xlUp).CurrentRegion.ClearContents
    End With
End Sub
 
Upvote 0
Works like a dream. Thank you very much for your help.
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,252
Members
449,075
Latest member
staticfluids

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