PC Review


Reply
Thread Tools Rate Thread

Combine, sort, & then create worksheet

 
 
J.W. Aldridge
Guest
Posts: n/a
 
      5th Nov 2008

I had trouble assembling a code to do the following, please assist....

1. Combine list from 3 specific sheets, into one "master" sheet.
(All data is on each sheet A:I - No headers)
Sheet 1 - "Apples"
Sheet 2 - "Oranges"
Sheet 3 - "Grapes

2. Sort Master sheet based on column A (groups), then B (names).

3. Create new sheets based on the names column B in the master sheet
(in the same order that the names appear).

 
Reply With Quote
 
 
 
 
Mauro Gamberini
Guest
Posts: n/a
 
      5th Nov 2008
You need a Sheet named Resume.

Public Sub m()

On Error GoTo ErrorRow

Dim sh As Worksheet
Dim shResume As Worksheet
Dim shNew As Worksheet
Dim rng As Range
Dim lLastRow As Long
Dim lFirstRow As Long

With Application
.ScreenUpdating = False
.Calculation = xlManual
.StatusBar = "Runs: Sub m()"
End With

Set shResume = Worksheets("Resume")

With shResume
.Rows("1:" & Rows.Count).Delete
.Select
ActiveSheet.UsedRange
End With

For Each sh In Worksheets
With shResume
lLastRow = _
.Range("A1").CurrentRegion.SpecialCells( _
xlCellTypeLastCell).Row + 1
End With
With sh
If .Name <> "Resume" Then
.Range("A1").CurrentRegion.Copy _
Destination:=shResume.Range( _
"A" & lLastRow)
End If
End With
Next

With shResume
.Rows("1:1").Delete
lLastRow = .Range("A1").CurrentRegion.SpecialCells( _
xlCellTypeLastCell).Row
.Range("A1").Select
.Range("A1:I" & lLastRow).Sort Key1:=Range("A1"), _
Order1:=xlAscending, Key2:=Range( _
"B1"), Order2:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase _
:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, _
DataOption2:=xlSortNormal
End With

Set shNew = Worksheets.Add
shResume.Range("B:B").Copy _
Destination:=shNew.Range("A1")

ExitRow:
Set rng = Nothing
Set sh = Nothing
Set shNew = Nothing
Set shResume = Nothing
With Application
.ScreenUpdating = True
.Calculation = xlAutomatic
.StatusBar = ""
End With
Exit Sub

ErrorRow:
MsgBox Err.Number & vbNewLine & Err.Description
Resume ExitRow

End Sub


--
---------------------------
Mauro Gamberini
http://www.riolab.org/
"J.W. Aldridge" <(E-Mail Removed)> ha scritto nel messaggio
news:6a6bdc33-f786-42f7-aa23-(E-Mail Removed)...
>
> I had trouble assembling a code to do the following, please assist....
>
> 1. Combine list from 3 specific sheets, into one "master" sheet.
> (All data is on each sheet A:I - No headers)
> Sheet 1 - "Apples"
> Sheet 2 - "Oranges"
> Sheet 3 - "Grapes
>
> 2. Sort Master sheet based on column A (groups), then B (names).
>
> 3. Create new sheets based on the names column B in the master sheet
> (in the same order that the names appear).
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HLookup, IF statement, multiple sort, somehow combine all of these =?Utf-8?B?R2l0YSBhdCBDQVNUTEU=?= Microsoft Excel Worksheet Functions 0 2nd May 2006 07:43 PM
Combine and sort =?Utf-8?B?VmFtcGlyZXNz?= Microsoft Excel Worksheet Functions 0 26th Apr 2006 05:59 PM
How do I sort a horizontal worksheet to create a vertical table =?Utf-8?B?VGhlIEhhbWJ1cmdlcjM2?= Microsoft Excel Worksheet Functions 1 29th May 2005 06:43 PM
Sort and Combine =?Utf-8?B?a2RyZXllcg==?= Microsoft Excel Programming 0 4th Feb 2005 09:39 PM
can you combine 2 fields to sort on together? =?Utf-8?B?RE0=?= Microsoft Access 2 13th Jan 2005 06:49 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:30 PM.