ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA to pull information (https://www.excelbanter.com/excel-programming/424970-vba-pull-information.html)

James

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.


joel

VBA to pull information
 
Try sorting on Key 1 = column F ascending and Key 2 column B descending

"James" wrote:

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.


James

VBA to pull information
 
unfortunately I do not think that will work because it will than seperate the
UWI.
B C E F G K
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
2 420390282800 8859 8886 F-4
1 420390282800 8868 8881 FRIO F-4
2 420390282800 9786 9882 ARMSTRONG
2 420390282800 10002 10437 LARSEN
1 420390282800 10004 10430 UNKOWN LARSEN

I added a bit more of my data, you will see that there are two unique UWI
values 420390281200 and 420390282800 if I sort on column F than column B it
will mix all the UWIs together. That is why I have to sort first on UWI.
Like last time column k is what I would like for it to return.

Thanks again.

"Joel" wrote:

Try sorting on Key 1 = column F ascending and Key 2 column B descending

"James" wrote:

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.


joel

VBA to pull information
 
Your data only showed 1 UWI.

Then Try sorting on Key 1 = Column A ascending, Key 2 = column F ascending,
and Key 3 column B descending


"James" wrote:

unfortunately I do not think that will work because it will than seperate the
UWI.
B C E F G K
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
2 420390282800 8859 8886 F-4
1 420390282800 8868 8881 FRIO F-4
2 420390282800 9786 9882 ARMSTRONG
2 420390282800 10002 10437 LARSEN
1 420390282800 10004 10430 UNKOWN LARSEN

I added a bit more of my data, you will see that there are two unique UWI
values 420390281200 and 420390282800 if I sort on column F than column B it
will mix all the UWIs together. That is why I have to sort first on UWI.
Like last time column k is what I would like for it to return.

Thanks again.

"Joel" wrote:

Try sorting on Key 1 = column F ascending and Key 2 column B descending

"James" wrote:

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.



All times are GMT +1. The time now is 01:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com