Home |
Search |
Today's Posts |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How about adding some line and change codes a little like below.
keiji elf27 wrote: Actually, previous post was wrong. I got it to work, but the problem is that it created 130 sheets and then errored out. Each sheet only had one line of information "Bob Phillips" wrote: You seem to have rolled individual lines in my code into 1. The NG also wrapped lines, see if this is any better Public Sub ProcessData() Const TEST_COLUMN As String = "A" '<=== change to suit Dim i As Long Dim LastRow As Long Dim NextRow As Long Dim sh As String add the code below Dim Acsh as Worksheet set Acsh=ActiveSheet Change the line below With ActiveSheet to With Acsh LastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row For i = 1 To LastRow If .Cells(i, "A").Value < sh Then sh = .Cells(i, "A").Value On Error Resume Next If Not Worksheets(sh).Name = sh Then _ Worksheets.Add.Name = sh On Error GoTo 0 If Worksheets(sh).Range("A1").Value = "" Then NextRow = 1 Else NextRow = Worksheets(sh).Range("A" & _ .Rows.Count).End(xlUp).Row + 1 End If .Cells(i, "A").Resize(, 2).Copy _ Worksheets(sh).Cells(NextRow, "A") End If Next i End With End Sub -- __________________________________ HTH Bob "elf27" wrote in message ... Bob, Thanks for your reply. I'm getting a compiling error though because of an Else without an If. In this portion of the code: If Worksheets(sh).Range("A1").Value = "" Then NextRow = 1 Else NextRow = Worksheets(sh).Range("A" & .Rows.Count).End(xlUp).Row + 1 I realize there's an if there, but Excel doesn't. Thanks again. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
copy selected rows to second worksheet (NOT Cut + Paste) | New Users to Excel | |||
Copy Row Paste Row (Seperate Sheet) | Excel Programming | |||
copy nonblank rows from many worksheets and paste them onto one worksheet | Excel Programming | |||
Cut and Paste to A Seperate Worksheet | Excel Programming | |||
Copy rows and paste to new worksheet | Excel Programming |