I am trying to take all the rows from the man page that cell row "E" has the same data and create a new tab named on that data and move them there.
Also the same with all other entries in row e. So at the end the first sheet "DATA" will be empty and deleted and I will have 6,8,10,20 new sheets each with only the pertinent data for that sheet. so if it was a list of colors - red - blue- green-yellow I would have four new sheets labeled one for each color and all the rows that have that color in that cell were moved to that new sheet.
Also the first row is a header row and needs to be on all the sheets.
But I can seem to get any closer....
Can anyone help?
'Add tabs
Set mysh = ActiveWorkbook.Sheets("Data")
lr = Range("A1").End(xlDown).row
For L = lr To 1 Step -1
For x = 1 To lr
If mysh.Cells(x, 7).Value = "" Then
GoTo row
End If
If mysh.Cells(x, 7).Value <> "" And counter = 0 Then
mystr = mysh.Cells(x, 7).Value
Set ws = ThisWorkbook.Sheets.Add(After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count))
ws.Name = mystr
mysh.Rows(1).Copy ws.Rows(1)
counter = 1
End If
If mysh.Cells(x, 7).Value = mystr Then
mysh.Rows(x).Copy ws.Rows(rownum2)
mysh.Rows(x).ClearContents
rownum2 = rownum2 + 1
End If
row:
rownum = rownum + 1
rownum2 = 2
Next x
counter = 0
Next L
Also the same with all other entries in row e. So at the end the first sheet "DATA" will be empty and deleted and I will have 6,8,10,20 new sheets each with only the pertinent data for that sheet. so if it was a list of colors - red - blue- green-yellow I would have four new sheets labeled one for each color and all the rows that have that color in that cell were moved to that new sheet.
Also the first row is a header row and needs to be on all the sheets.
But I can seem to get any closer....
Can anyone help?
'Add tabs
Set mysh = ActiveWorkbook.Sheets("Data")
lr = Range("A1").End(xlDown).row
For L = lr To 1 Step -1
For x = 1 To lr
If mysh.Cells(x, 7).Value = "" Then
GoTo row
End If
If mysh.Cells(x, 7).Value <> "" And counter = 0 Then
mystr = mysh.Cells(x, 7).Value
Set ws = ThisWorkbook.Sheets.Add(After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count))
ws.Name = mystr
mysh.Rows(1).Copy ws.Rows(1)
counter = 1
End If
If mysh.Cells(x, 7).Value = mystr Then
mysh.Rows(x).Copy ws.Rows(rownum2)
mysh.Rows(x).ClearContents
rownum2 = rownum2 + 1
End If
row:
rownum = rownum + 1
rownum2 = 2
Next x
counter = 0
Next L