Computing.Net > Forums > Office Software > Excel Macro - sorting data

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

Excel Macro - sorting data

Reply to Message Icon

Name: ljmsbe
Date: May 8, 2006 at 07:00:37 Pacific
OS: x
CPU/Ram: x
Product: x
Comment:

Hello!
I am a mechanical engineer by trade and am working in Excel to manipulate data. I have written macros in the past, but have come to a stumbling block. For simplicity say I have a column of timing information such as:
Time Sequence
1
3
5
7
Then I have another column of sequential time:
Time actual
0
1
2
3
4
5
etc.
I want to be able to take the first to values of the first column, search the second solumn for any values between those numbers, then copy those rows to a new spreadsheet, then loop back to search for the next two sets of numbers. So I want to search my actual time for values between 1 and 3 and put them all in a new sheet, then search for values between 3 and 5 and put those in another new sheet, etc.
Does anyone have any suggestions? Right now I'm working with an If . . .and . . then statement, but I'm struggling with what to put after the "then" part.
Thanks!
Laura




Sponsored Link
Ads by Google

Response Number 1
Name: rhawk7938
Date: May 8, 2006 at 11:46:32 Pacific
Reply:

This is pretty basic but it might give you some ideas. (I referenced sheet2 in the same workbook, for the result but you could just as easily reference a different workbook.) Hope this helps you.


Sub test()
Set MyRange = Range("B1:B8")

For X = 1 To 8 Step 2


For Each cel In MyRange
celval = cel.Value
If celval > Cells(X, 1) And celval < Cells(X + 1, 1) Then


Sheet2.Cells(X, 5) = celval
End If


Next

Next
End Sub


0
Reply to Message Icon

Related Posts

See More


Excel Concatenation formu... Word 2003 - Macros to Aut...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Office Software Forum Home


Sponsored links

Ads by Google


Results for: Excel Macro - sorting data

Excel- Sorting data - how to? www.computing.net/answers/office/excel-sorting-data-how-to/1143.html

Macro for sorting data on multiple sheets www.computing.net/answers/office/macro-for-sorting-data-on-multiple-sheets/9646.html

Run Excel Macro as Automated Task on Server www.computing.net/answers/office/run-excel-macro-as-automated-task-on-server/9661.html