• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 134
  • Last Modified:

move data to new sheets with same name

from my active sheet I need to move data to a new sheet that has the same name as the name in column J [Ref]

so Rows go from A to S and I need all data from activesheet for CLOVC to be put on Sheet Named ClOVC, all data for BKIDQ to be put on sheet named BKIDQ etc etc

   Ref
CLOVC
CLOVC
CLOVC
BKIDQ
BKIDQ
CLOVC
SUUKG
MSSU0

Thanks in Advance.
0
Jagwarman
Asked:
Jagwarman
  • 3
  • 2
1 Solution
 
JagwarmanAuthor Commented:
sorry aditional info, I need the header row from my active sheet to be included on each sheet.

Thanks
0
 
Rgonzo1971Commented:
Hi,

pls try

Sub macro()
Set OrigSh = ActiveSheet
For Each c In Range(Range("J2"), Range("J" & Rows.Count).End(xlUp))
    If c.Offset(0, -8) = Date Then
        On Error Resume Next
        Set Sh = Nothing
        Set Sh = ActiveWorkbook.Worksheets(c.Value)
        On Error GoTo 0
        If Sh Is Nothing Then
            ActiveWorkbook.Sheets.Add After:=Worksheets(Worksheets.Count)
            Worksheets(Worksheets.Count).Name = c.Value
            OrigSh.Range("A1").EntireRow.Copy ActiveWorkbook.Worksheets(c.Value).Range("A1")
        End If
        c.EntireRow.Copy ActiveWorkbook.Worksheets(c.Value).Range("A" & Rows.Count).End(xlUp).Offset(1)
    End If
Next

Open in new window

Regards
0
 
JagwarmanAuthor Commented:
its great except it did not put the header row in in left row 1 blank
0
 
Rgonzo1971Commented:
My code copies Row 1 (EDIT not A) in the active sheet and copies it in the sheet but only if the sheet does not already exist
0
 
JagwarmanAuthor Commented:
My apologies that is brilliant. Thanks for all your help. Have a great weekend.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now