Move data from sheet to sheet based on ColA
Thanks don. The code creates the sheets, but does not copy any data
to them. Looks like the variable dlr is always "empty", and since its
part of the copy to range, never pastes.
On Aug 11, 8:13 am, "Don Guillett" wrote:
Try this. It will make the sheet if necessary and append the data to the
appropriate sheet.There should be only ONE dot if front of each with segment
such as .range, .showalldata, etc. Assign to a button or shape.
Sub CopyDaily()
Application.ScreenUpdating = False
With Sheets("Data")
lr = .Cells(Rows.Count, "a").End(xlUp).Row
.Range("A1:A" & lr).AdvancedFilter Action:=xlFilterInPlace, Unique:=True
For Each c In .Range("a2:a" & lr).SpecialCells(xlVisible)
On Error Resume Next
If Worksheets(c.Value) Is Nothing Then
Worksheets.Add(After:=Worksheets(Worksheets.Count) ).Name = c
End If
.ShowAllData
.Range("a1:a" & lr).AutoFilter field:=1, Criteria1:=c
dlr = Sheets(c.Value).Cells(Rows.Count, "a").End(xlUp).Row + 1
.Range("a2:a" & lr).Copy Sheets(c.Value).Range("a" & dlr)
Next c
.ShowAllData
.Range("a1:a" & lr).AutoFilter
End With
Application.ScreenUpdating = True
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
"Steve" wrote in message
oups.com...
Hi Don. Because the newly created sheets will be automatically
emailed to the business owners. Also, the sheets will be printed and
added to a monthly book that goes out.
On Aug 10, 3:35 pm, "Don Guillett" wrote:
Why not just use datafilterautofilter
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
"Steve" wrote in
message
roups.com...
Hi everyone. If I have a sheet called Data, is there a way to have
vba scan all of column A, identify unique values in column A, and then
parse out the entire rows into new sheets? So for instance, if the
values in ColumnA are Blue, Green and Yellow. VBA wold create 3 new
sheets. In the Blue sheet, there would only be records that had Blue
in Column A, and so forth. The only catch is the number of unique
values in ColA can change from month to month. Thanks!- Hide quoted
text -
- Show quoted text -- Hide quoted text -
- Show quoted text -
|