View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default Copy data to different sheets

Try the below.

Sub Copyrows()
Dim wb As Workbook, ws1 As Worksheet, ws2 As Worksheet
Dim lngRow As Long, lngLastRow1 As Long, lngLastRow2 As Long
Set wb = ActiveWorkbook
Set ws1 = wb.Sheets("AllData")
lngLastRow1 = ws1.Cells(Rows.Count, "A").End(xlUp).Row
For lngRow = 2 To lngLastRow1
Set ws2 = wb.Sheets(CStr(ws1.Range("A" & lngRow)))
lngLastRow2 = ws2.Cells(Rows.Count, "A").End(xlUp).Row
ws1.Rows(lngRow).Copy ws2.Rows(lngLastRow2 + 1)
Next
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"James Merrill" wrote:

Bare with me here as I try to explain this because it is somewhat confusing,
I will try to simplify as much as possible. I have a workbook with multiple
sheets. The first sheet (AllData) contains all my data. I have 3 columns of
data: Subject, Student, and Grade. Looks like this:

SUBJECT STUDENT GRADE
math john doe A
science jane doe B
english james C

There are three subsequent sheets named according to the subject: "math",
"science", "english" I want to move all the "math" data onto the math sheet,
science data onto science sheet, and engnlish data onto english sheet.

This is a simplified version, as my real example has 140 different
"subjects" and about 40,000 rows, so doing it manually is a bit out of the
question. Let me know if any of that didnt make sense or if i can further
clarify.

Thanks,
James