View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
James James is offline
external usenet poster
 
Posts: 542
Default VBA to pull information

I have been attempting to complete this all day yesterday, and I think this
situation would be best suited for VBA.

Here is a small subset of my data )B, C, E, F, G, K are columns in data)
B C E F G K
UWI Up Perf Lwer Perf Formation
2 420390281200 10426 10440 CAMPBELL
2 420390281200 10681 10869 LARSEN
1 420390281200 10424.5 10442 FRIO CAMPBELL
1 420390281200 10696 10176 UNKNOWN LARSEN
1 420390281200 11117.5 11120.5 UNKNOWN

I have a group of wells with the same UWI# but these came from two different
data sets. The 1 represents a data set and the 2 represents another data set,
I want to merge the formation names from data set 2 into the data set 1.

I only want to merge the formation names when the the "Up Perf" and "Lwer
Per" of data set 1 falls into the range of data set 2, and here is one of the
issues if the "Up Perf" and "Lwer Per" of data set 1 is + or - 3 ft I still
want to pull the formation name of data set 2 into data set 1.

The example above
2 420390281200 10426 10440 CAMPBELL
1 420390281200 10424.5 10442 FRIO CAMPBELL

Because 10424.5 and 10442 (FRIO) is within the 10426 and 10440 (CAMPBELL)
+-3ft it is still returning CAMPBELL.

2 420390281200 10681 10869 LARSEN
1 420390281200 10696 10176 UNKNOWN LARSEN

Because 10696 and 10176 (UNKOWN) is between 10681 and 10869 (LARSEN) I need
is to return LARSEN.

2 420390281200 10426 10440 CAMPBELL
2 420390281200 10681 10869 LARSEN
1 420390281200 11117.5 11120.5 UNKNOWN

Because 11117.5 and 11120.5 does not fall into any of the data set 2 range
nothing needs to happen.

I appreciate any help.

All the formation names that are trying to be merged from data set should
populate on the data set 1 rows. If at all possible I would like the results
to return in column K.