Hello,
I've been working on creating this line of script but keep getting errors. I need the first row on the first worksheet to copy to the remaining worksheets on the first row. Literally row 1 from the first sheet will pasted in row 1 of the remaining sheets. Here's the final script that I tried.
The Set r statement is all ways being highlighted even if i call the worksheet by name.Sub Top_Row_Paste() Dim ws As Worksheet, i As Integer, r As Range Set r = Worksheets(1).Range("A1") Set ws = Worksheet(i) i = i + 1 For Each ws In ActiveWorkbook.Worksheets r.EntireRow.Copy Destination:=Range("A1") Next ws End Sub
Thanks for the help.
Hello keith156,
You didn't qualify your destination range with the object variable ws.
Addendum: Worksheets index starts at 1, not 0Sub Top_Row_Paste() Dim ws As Worksheet, i As Integer, r As Range Set r = Worksheets(1).Range("A1") Set ws = Worksheet(i) i = i + 1 For Each ws In ActiveWorkbook.Worksheets r.EntireRow.Copy Destination:=ws.Range("A1") Next ws End Sub
Last edited by Leith Ross; 12-30-2009 at 03:04 PM.
Sincerely,
Leith Ross
Remember To Do the Following....
1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.2. Thank those who have helped you by clicking the Starbelow the post.
3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
Leith,
Thanks for the reply. I tried to add the ws to the statement and got another error "mismatch" and "Script out of Range" errors. However, I changed the script to the following and it worked.
Thank you for the response!Sub Top_Row_Paste() Dim ws As Variant, i As Integer, r As Range Set r = Worksheets(1).Range("A1") Set ws = Worksheets(Worksheets.Count) i = i + 1 For Each ws In ActiveWorkbook.Worksheets r.EntireRow.Copy Destination:=ws.Range("A1") Next ws End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks