Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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

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
NextNext
End Sub

![]() |
Excel Concatenation formu...
|
Word 2003 - Macros to Aut...
|

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