MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Vb macro


Posted by Del Booth on August 24, 2001 4:15 AM

Hi.

I am trying to write a vb macro to read in a
x cordinate from a data column, then find that value
in the original data set and match it to the
corresponding y value.

Thanks
Del


Posted by Dax on August 24, 2001 5:56 AM

Do you mean that the Y value is in the same row as the X row? If so you could use the Vlookup worksheet function in your code. For example:-

Say column A contains your Y values and column B contains your X values and you want to find the value of Y that matches X=7

Sub FindXValue()
Dim dblXValue As Double
dblXValue = 7
MsgBox WorksheetFunction.VLookup(dblXValue, Sheet1.Range("A:B"), 2, False)
End Sub

If you need any further help please post.

Regards,
Dax.