match cell value to worksheet name and copy row data

Fazila

Board Regular
Joined
Nov 19, 2014
Messages
163
I have a problem very similar to the one posted on this thread https://www.mrexcel.com/forum/excel...-cell-value-worksheet-name-copy-row-data.html and the code supplied by mumps look very promising

Code:
Sub CopyRows()
    Dim bottomD As Integer
    bottomD = Range("A" & Rows.Count).End(xlUp).Row
    Dim c As Range
    Dim ws As Worksheet
    For Each c In Sheets("subjectnames").Range("A1:A" & bottomD)
        For Each ws In Sheets
            ws.Activate
            If ws.Name = c Then
                c.EntireRow.Copy Cells(Rows.Count, "A").End(xlUp)
    End If
        
        Next ws
        
        Next c
            
End Sub

The only problem is it does not appear to copy the row across or go on to the next c

any ideas?

Thanks
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Code:
Sub CopyHeader()

 Dim wkSht As Worksheet
 Dim c As Range
 
  For Each wkSht In Sheets


    For Each c In Sheets("subjectnames").Range("A1:A23")
                   
            If c.Value = wkSht.Name Then


            wkSht.Range("A1").Copy Destination:=c.Offset(0, 1)
       
        End If
    Next c
    Next wkSht
    
     
End Sub

This looks good as well but this time it won't go to the next worksheet :confused:
 
Upvote 0
My mistake it is going to the next c but it is not pasting the row to row 1 please any help would be greatly appreciated
 
Upvote 0
realised the row was getting copied but at the end of the sheet rather than in row one changing cells to cells(1,1) helped resolve that
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,199
Members
453,022
Latest member
RobertV1609

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