Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default Combine, sort, & then create worksheet


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).

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Combine, sort, & then create worksheet

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" ha scritto nel messaggio
...

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
create Macro €“ select data, sort by acc no., yr, part no, create P Johnny Excel Programming 0 November 22nd 06 03:18 PM
HLookup, IF statement, multiple sort, somehow combine all of these Gita at CASTLE Excel Worksheet Functions 0 May 2nd 06 07:43 PM
Combine and sort Vampiress Excel Worksheet Functions 0 April 26th 06 05:59 PM
How do I sort a horizontal worksheet to create a vertical table The Hamburger36 Excel Worksheet Functions 1 May 29th 05 06:43 PM
Sort and Combine kdreyer Excel Programming 0 February 4th 05 09:39 PM


All times are GMT +1. The time now is 06:28 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"