Organizing a list of data from a table

chrgrose

Board Regular
Joined
Sep 11, 2009
Messages
80
I have a large table of data with various values. I want to find all the values in the table which satisfy some condition (eg. between 5 and 6) and copy them individually as a list.

I can't simply find how many there are which satisfy the condition because they are not all the same. If it helps, I can set all values in the table which do not satisfy the condition to zero or some other value.

How could this best be accomplished? I can use native code or VBA.

Thanks in advance!
 
If I understand correctly try

Code:
Sub Numbers2()
Dim r As Range, c As Range, i As Currency
Set r = Range("A1:J3")
For Each c In r
    For i = 0 To 9
        If c.Value >= i And c.Value <= i + 1 Then
            Cells(Rows.Count, i + 12).End(xlUp).Offset(1).Value = c.Offset(3).Value
            Exit For
        End If
    Next i
Next c
End Sub
 
Upvote 0

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Thanks, this works just as desired. One question though: what is the function of Rows.Count in this code? It seems this is where you are telling the sheet to paste the data, but I don't see how it is accomplishing that task.

I understand the i+12 part, but not the use of rows.count.
 
Upvote 0
Cells(Rows.Count, i + 12)

returns the bottom cell in that column.

Cells(Rows.Count, i + 12).End(xlUp)

looks up from there to find the first filled cell (when looking up, i.e. the last filled cell when looking down).

Cells(Rows.Count, i + 12).End(xlUp).Offset (1)

offsets that by one row to give the first empty cell when looking down the column.
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,558
Members
452,928
Latest member
101blockchains

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top