trying to sort out data

quapple

New Member
Joined
May 28, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I have a long table of data, the first column is the sample ID (in yellow, red) and the corresponding rows are the data associated with that sample ID (see photo below). I want to extract data in between a certain sample ID range, for example, I want to take the Au, Ag, AI etc. data associated with sample IDs from 10000 and 10999 and put this in a new sheet. Can this be done with vlookup?
 

Attachments

  • Screen Shot 2021-06-03 at 7.25.03 PM.png
    Screen Shot 2021-06-03 at 7.25.03 PM.png
    149.2 KB · Views: 8

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
If you made a list of the SampleIDs you could VLOOKUP each column individually, but it's very inefficient.

This code will let you type numbers to search between and create the sheet for you

VBA Code:
Sub movedata()

Dim rownum As Long
Dim rownum2 As Long
Dim fromVal As Long
Dim toVal As Long
Dim ws As Worksheet
Dim ws2 As Worksheet

fromVal = InputBox("Enter Value to Search From")
toVal = InputBox("Enter Value to Search To")
rownum = 6
rownum2 = 6
Set ws = ActiveSheet
Sheets.Add
ActiveSheet.Name = ("Paste Sheet")
Set ws2 = Sheets("Paste Sheet")

ws.Rows("2:5").Copy ws2.Rows("2:5")

Do Until ws.Cells(rownum, 1) = ""
    If ws.Cells(rownum, 1) >= fromVal And ws.Cells(rownum, 1) <= toVal Then
        ws.Rows(rownum).Copy ws2.Rows(rownum2)
        rownum2 = rownum2 + 1
    End If
rownum = rownum + 1
Loop

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,038
Messages
6,122,798
Members
449,095
Latest member
m_smith_solihull

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