Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Data sorting to a new sheet

Thanks for your help I will fiddle around with it this week end

"Joel" wrote:

the sheet names can be iether of the following

Sheets(1) - the first sheet in order in the workbook. the 2nd sheet would
be sheets(2)

Sheets("Sheet1") - the sheet name in double quotes. can be "ALD"

sht = "ALD" - using a varible with the sheet name in double quotes.

sheets(sht) - no double quote



No sure why it crashed unless it has to do something with you changing sheet
names. You may not have any data in column A in the first sheet.


"Novice Lee" wrote:

If I change the Sheet name (sheet 2) to ALD Would I change Sheets(2) to ALD?

"Joel" wrote:

Sub MoveData()

'clear sheet 2 and copy header row
With Sheets(2)
Cells.ClearContents
Sheets(1).Rows(1).Copy Destination:=.Rows(1)
End With

'clear sheet 3 and copy header row
With Sheets(3)
Cells.ClearContents
Sheets(1).Rows(1).Copy Destination:=.Rows(1)
End With

Sh1RowCount = 2
Sh2RowCount = 2
Sh3RowCount = 2

With Sheets(1)
Do While .Range("A" & Sh1RowCount) < ""
If .Range("B" & Sh1RowCount) < "" Then
.Row(Sh1RowCount).Copy _
Destination:=Sheets(2).Row(Sh2RowCount)
Sh2RowCount = Sh2RowCount + 1
End If
If .Range("C" & Sh1RowCount) < "" Then
.Row(Sh1RowCount).Copy _
Destination:=Sheets(3).Row(Sh3RowCount)
Sh3RowCount = Sh3RowCount + 1
End If
Sh1RowCount = Sh1RowCount + 1
Loop
End With

'Sort sheet 3
With Sheets(3)

LastRow = .Range("A" & Rows.Count).End(xlUp).Row
Set SortRange = .Rows("2:" & LastRow)
SortRange.Sort _
Key1:=Range("A2"), _
Order1:=xlAscending, _
Key2:=Range("C2"), _
Order2:=xlAscending, _
Header:=xlNo
End With
End Sub



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
Sorting data in one sheet Gwen Excel Worksheet Functions 4 May 20th 09 11:36 PM
Sorting Data from a different sheet VoxBox-Richard Excel Worksheet Functions 1 November 4th 08 04:58 PM
sorting data from one sheet to another rldjda Excel Worksheet Functions 4 March 22nd 08 08:01 PM
SORTING DATA TO ANOTHER SHEET cityfc Excel Worksheet Functions 0 January 11th 06 11:40 PM
SORTING DATA TO ANOTHER SHEET cityfc Excel Worksheet Functions 0 January 11th 06 11:39 PM


All times are GMT +1. The time now is 02:21 AM.

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

About Us

"It's about Microsoft Excel"