vb code to copy and list selected row to diff sheets

P

pvkutty

I am working with workbook with 30sheets for each day x each worksheet having
same headers and colmuns x I want to copy selected rows to corresponding
sheets with different name . eg.
date name details amount type
13feb kk ccj/dxb 1300 inv
14feb pv ccj/auh 1200 alh
I would like to copy first row to a sheet named inv and second row to sheet
names alh. can u adv me the code to be used
 
J

Jacob Skaria

Try the below code with all the sheets...

Sub CopyRowstoDifferentSheets()
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.ActiveSheet
lngLastRow1 = ws1.Cells(Rows.Count, "E").End(xlUp).Row
For lngRow = 2 To lngLastRow1
Set ws2 = wb.Sheets(CStr(ws1.Range("E" & lngRow)))
lngLastRow2 = ws2.Cells(Rows.Count, "E").End(xlUp).Row
ws1.Rows(lngRow).Copy ws2.Rows(lngLastRow2 + 1)
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top