Quantcast
Channel: Excel IT Pro Discussions forum
Viewing all articles
Browse latest Browse all 11829

Seeking a macro to take multiple horizontal sections and paste each one to it's own worksheet (from an external file)!

$
0
0

Hello all, and thank you in advance for any assistance in tackling this endeavor.

One of my companie's employees has a spreadsheet that comes in from our field office.  On this spread sheet are sections that are randomly spaced (so I can not count on calling specific cells).  Each section pertains to a single well.  Within that section, each line contains approx. 18 columns of production data for approx 17 rows of data.

Three of these rows are important to this project.  

Currently, my coworker copies these three rows (by hand), to a new spreadsheet and in doing so, she copies them vertically.

The end product is a spreadsheet with a worksheet for each well.  On each well's worksheet is the name of the well, and then 3 columns (one for each of the three rows).  Each columns contains the 18 or so data points that were previously in horizontal rows)

I'm sure that is somewhat confusing as it stands.  I can provide a sample of the source excel sheet to anyone interested.  Meanwhile here are some more details on the layout:

I previously mentioned that each well's sections has 3 rows that are of importance.  Column B contains the names of the datasets, and the three important rows in each section always have the same name in this column.  So I figure that a statement that does something like search for the values "Total Gas", "Corrected Intellisite", and "Water" would be able to always locate the three important rows.

I haven't been able to come up with a way to identify each wells section yet.  While a loop that searches the previous terms would be able to identify and copy the three important rows for each well... it wouldn't give any identifying information to note which well each dataset belongs to.

Maybe one of the following patterns is useful?

1: The well name is always in column A, but sometimes there is other info in column A as well.  Well names however are always proceeded by a cell border (no idea if a macro can take that into account).

2: The well name is always 7 cells above and 1 cell to the left of the "Total Gas" cell, which is one of the important cells needed for copying the rows into columns.  Maybe the macros could do some sort of math once it finds the "Total Gas" cell, to derive the cell # that the well name is in and copy it over first?

I read up and looked over the macro that Hans provided in a somewhat similar question where a user needed to copy data that was horizontal to a vertical spreadsheet.  However I was not able to work out how to adapt all that to a process that was more selective about what it copied and used new worksheets for each section.

The final challenge is that the source worksheet exists on a shared drive.  The ultimate goal here would be to have a macro in a spreadsheet that went out, referenced or grabbed the data from the source worksheet, and copied the results into blank worksheets in the spreadsheet that contains the macro.

I hope I'm not asking too much and that I have provided enough information.  I am familiar with vbscript in access, however I have never written an excel macro before, so I am looking forward to this as quite a learning experience.

Thank you again to anyone who can provide assistance.


Viewing all articles
Browse latest Browse all 11829

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>