Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 661
Default Worksheet Data Sorting

I would like to know if anyone has a program which will sort data on a
worksheet. Basically I have a task that involves viewing a huge worksheet
called (Raw Data)filled with heaps of cases and I have to cut and paste a
line where the beginning cell is "X' for example and then paste that line to
'X's seperate sheet in the the workbook. I have about 50 different x's and
this task is sooo time consuming. Is there a program which will recognise
each line by the first cell cut the line and paste it to the specific sheet,
and then so on for the next value???
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Worksheet Data Sorting

Look at Ron deBruin's site for some sample code:

http://www.rondebruin.nl/copy5.htm

--
Regards,
Tom Ogilvy


"Paul" wrote in message
...
I would like to know if anyone has a program which will sort data on a
worksheet. Basically I have a task that involves viewing a huge worksheet
called (Raw Data)filled with heaps of cases and I have to cut and paste a
line where the beginning cell is "X' for example and then paste that line

to
'X's seperate sheet in the the workbook. I have about 50 different x's and
this task is sooo time consuming. Is there a program which will recognise
each line by the first cell cut the line and paste it to the specific

sheet,
and then so on for the next value???



  #3   Report Post  
Posted to microsoft.public.excel.programming
A C A C is offline
external usenet poster
 
Posts: 8
Default Worksheet Data Sorting


"Paul" wrote in message
...
I would like to know if anyone has a program which will sort data on a
worksheet. Basically I have a task that involves viewing a huge worksheet
called (Raw Data)filled with heaps of cases and I have to cut and paste a
line where the beginning cell is "X' for example and then paste that line

to
'X's seperate sheet in the the workbook. I have about 50 different x's and
this task is sooo time consuming. Is there a program which will recognise
each line by the first cell cut the line and paste it to the specific

sheet,
and then so on for the next value???


Hello

Try the simple macro below. It is very simplistic as it is difficult to
write something specific for your app without knowing more about your app :)

Major assumptions as written (although very easy to change):
* Raw data is in a table starting in cell A1 in a sheet called "RawData"
* No blank rows in column 1 allowed within this table of data
* Each "item" will get copied to its own worksheet. Each row of new data
is inserted into the first row in these new worksheets, so the data will be
in reverse order to the original raw data order
* Entire row is copied over
* Data is removed from the raw data worksheet after it is copied over
* Sorting the raw data will help speed wise, but is not necessary
* May fail if formulas were present in the raw data

Hopefully this will help, or be a start for you at least.

Regards
A


Option Explicit
Sub Macro1()
'Assumptions: No blank rows in the raw data list
' Raw data starts in row1, col1 in a worksheet called "RawData"
' Entire line is cut and pasted
' Pasting data into top row of each new worksheet. This
reverses the order of the data
' More efficient if raw data is sorted, but not required
' Assumes raw data only, no formulas

Dim strCurrentValue As String
Dim rawWorksheet As Worksheet

strCurrentValue = "rubbishStartingValue"

Set rawWorksheet = Worksheets("RawData")
Range("A1").Activate
'Keep looping over the raw data list until a blank cell is encountered in
the first column
While (ActiveCell.Value < "")
If ActiveCell < strCurrentValue Then
'New item identified, make a new worksheet if it doesnt already
exist
'To check for the worksheet existing try to access it, an error will
be thrown if it doesnt exist and we can detect this error
On Error Resume Next
ActiveWorkbook.Worksheets(ActiveCell.Value).Activa te
If Err Then
'Worksheet didnt exist so Excel threw an error
Sheets.Add after:=Sheets(Worksheets.Count)
rawWorksheet.Activate
Sheets(Worksheets.Count).Name = ActiveCell.Value
End If
Err.Clear 'clear any errors
strCurrentValue = ActiveCell.Value
End If
'Cut and paste over the row of data
rawWorksheet.Activate
Rows(1).Select
Selection.Cut
Sheets(strCurrentValue).Activate
'Paste the cut row into the top row of the worksheet
Range("A1").Activate
Selection.Insert shift:=xlDown
rawWorksheet.Activate
Selection.Delete
Wend

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 on a worksheet for different users (shifts) Ron Zack Excel Discussion (Misc queries) 4 November 9th 07 10:35 PM
sorting data on protected worksheet Sue Excel Discussion (Misc queries) 20 November 7th 06 07:31 PM
Sorting and copying data to another worksheet in a workbook. Geo Excel Discussion (Misc queries) 3 June 5th 06 09:58 PM
use data on master worksheet for sorting Ken New Users to Excel 1 December 7th 04 03:30 AM
Protected worksheet VS. sorting data George[_14_] Excel Programming 1 July 30th 03 10:36 PM


All times are GMT +1. The time now is 04:15 PM.

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"