Auto import data from text files into Excel spreadsheet and merge

scottryan

New Member
Joined
Aug 3, 2016
Messages
4
I'm trying to automate my data import method to save time. Right now 2 text files are created and saved in a folder before being opened in Excel, the required data highlighted and then copied and pasted into the relevant cells in the ROPdata sheet shown below.

The first file is called ROP-Gas.txt and contains 3 columns delimited by spaces. The first column is Depth, second is ROP and the third is Gas. After going through Text Import Wizard, it looks like this:

ROP-Gas.txt

ABC

<tbody>
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]1[/TD]
[TD="align: right"]500[/TD]
[TD="align: right"]0.6[/TD]
[TD="align: right"]2.18[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]2[/TD]
[TD="align: right"]500.2[/TD]
[TD="align: right"]0.6[/TD]
[TD="align: right"]2.18[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]3[/TD]
[TD="align: right"]500.4[/TD]
[TD="align: right"]0.6[/TD]
[TD="align: right"]2.18[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]4[/TD]
[TD="align: right"]500.6[/TD]
[TD="align: right"]0.6[/TD]
[TD="align: right"]2.18[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]5[/TD]
[TD="align: right"]500.8[/TD]
[TD="align: right"]0.6[/TD]
[TD="align: right"]2.19[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]6[/TD]
[TD="align: right"]501[/TD]
[TD="align: right"]0.6[/TD]
[TD="align: right"]2.19[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]7[/TD]
[TD="align: right"]501.2[/TD]
[TD="align: right"]0.6[/TD]
[TD="align: right"]2.2[/TD]

</tbody>

So, the file is opened and the ROP and Gas columns highlighted and copied to the clipboard before going to the ROPdata sheet and the matching Depth value and pasted in.

The second file is called gamma.las that contains a header and columns of data. The header isn't relevant but the columns are - the first is Depth and the second is Gamma. It's also space delimited and looks like this after going through the Import Text Wizard:

gamma.las

ABCDEF
~VERSIONINFORMATION
VERS.:CWLSLOGASCII
WRAP.NO:ONELINEPER
PHXV.1.4.1.14:PhoenixLASGeneratorVersion
VDAT.:PhoenixLASBuild
~WELLINFORMATION
#MNEM.UNITDATADESCRIPTION
#-------------------------------------------
STRT.M:STARTDEPTH
STOP.M:STOPDEPTH
STEP.M:STEP
NULL.:NULLVALUE
WELL.:WellName
RIG.:RigName
COMP.:ClientName
CTRY.CA:Country
PROV.MB:Province
LOC.:SurfaceLocation
UWI.:UniqueWellID
PDAT.GroundLevel:Permanent
DMF.KellyBushing:Drilling
KB.M:KellyBushing
GL.M:GroundLevel
DATE.:
CREATED.:
LIC.:WellLicenseNumber
LATI.DEG:Latitude
LONG.DEG:Longitude
SRVC.:ServiceCompany
FLD.:Field
~CURVEINFORMATION
#MNEM.UNITAPICODESCURVEDESCRIPTION
#-------------------------------------------
DEPT.M:DEPTH
MG1C.API:GammaRay(Corrected)
DVER.M:HoleTVD
ROPA.M/HR:RateofPenetration
~ADEPTMG1CDVERROPA

<tbody>
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]1[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]2[/TD]

[TD="align: right"]2[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]3[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]4[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]5[/TD]

[TD="align: right"]########[/TD]
[TD="align: right"]8:58:00[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]6[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]7[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]8[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]9[/TD]

[TD="align: right"]139[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]10[/TD]

[TD="align: right"]2175[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]11[/TD]

[TD="align: right"]0.2[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]12[/TD]

[TD="align: right"]-999.25[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]13[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]14[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]15[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]16[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]17[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]18[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]19[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]20[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]21[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]22[/TD]

[TD="align: right"]535.53[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]23[/TD]

[TD="align: right"]531.33[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]24[/TD]

[TD="align: right"]2018[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]30[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]25[/TD]

[TD="align: right"]2018[/TD]
[TD="align: right"]7[/TD]
[TD="align: right"]3[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]26[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]27[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]28[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]29[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]30[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]31[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]32[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]33[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]34[/TD]

[TD="align: right"]1[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]35[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]36[/TD]

[TD="align: right"]960[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]37[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]38[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]39[/TD]
[TD="align: right"]500[/TD]
[TD="align: right"]34.94[/TD]
[TD="align: right"]139[/TD]
[TD="align: right"]-999.25[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]40[/TD]
[TD="align: right"]500.2[/TD]
[TD="align: right"]36.39[/TD]
[TD="align: right"]139.2[/TD]
[TD="align: right"]24.87[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]41[/TD]
[TD="align: right"]500.4[/TD]
[TD="align: right"]37.85[/TD]
[TD="align: right"]139.4[/TD]
[TD="align: right"]50.25[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]42[/TD]
[TD="align: right"]500.6[/TD]
[TD="align: right"]39.3[/TD]
[TD="align: right"]139.6[/TD]
[TD="align: right"]52.44[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]43[/TD]
[TD="align: right"]500.6[/TD]
[TD="align: right"]39.85[/TD]
[TD="align: right"]139.8[/TD]
[TD="align: right"]58.81[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]44[/TD]
[TD="align: right"]500.8[/TD]
[TD="align: right"]40.39[/TD]
[TD="align: right"]140[/TD]
[TD="align: right"]69.81[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]45[/TD]
[TD="align: right"]501[/TD]
[TD="align: right"]40.94[/TD]
[TD="align: right"]140.2[/TD]
[TD="align: right"]76.01[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]46[/TD]
[TD="align: right"]501.2[/TD]
[TD="align: right"]41.49[/TD]
[TD="align: right"]140.4[/TD]
[TD="align: right"]74.11[/TD]

</tbody>

Same thing with the gamma.las file - the gamma values are highlighted, copied to the clipboard and then pasted into the ROPdata sheet based on the matching depth values.

Excel tables to the web >> Excel Jeanie HTML 4

ROPdata

ABCDEFGHI

<tbody>
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]1[/TD]
[TD="align: center"]Slide[/TD]
[TD="align: center"]Depth[/TD]
[TD="align: center"]ROP (min/m)[/TD]
[TD="align: center"]Gas (%)[/TD]
[TD="align: center"]Gamma (cps)[/TD]
[TD="align: center"]TVD[/TD]
[TD="align: center"]Subsea Elevation[/TD]
[TD="align: center"]Plotted Gas[/TD]
[TD="align: center"]Plotted Gamma[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]2[/TD]

[TD="align: center"]500.0[/TD]

[TD="align: center"]496.62[/TD]
[TD="align: center"]-496.62[/TD]
[TD="align: center"]0.0[/TD]
[TD="align: center"]0.0[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]3[/TD]

[TD="align: center"]500.2[/TD]

[TD="align: center"]496.82[/TD]
[TD="align: center"]-496.82[/TD]
[TD="align: center"]0.0[/TD]
[TD="align: center"]0.0[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]4[/TD]

[TD="align: center"]500.4[/TD]

[TD="align: center"]497.02[/TD]
[TD="align: center"]-497.02[/TD]
[TD="align: center"]0.0[/TD]
[TD="align: center"]0.0[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]5[/TD]

[TD="align: center"]500.6[/TD]

[TD="align: center"]497.22[/TD]
[TD="align: center"]-497.22[/TD]
[TD="align: center"]0.0[/TD]
[TD="align: center"]0.0[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]6[/TD]

[TD="align: center"]500.8[/TD]

[TD="align: center"]497.42[/TD]
[TD="align: center"]-497.42[/TD]
[TD="align: center"]0.0[/TD]
[TD="align: center"]0.0[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]7[/TD]

[TD="align: center"]501.0[/TD]

[TD="align: center"]497.61[/TD]
[TD="align: center"]-497.61[/TD]
[TD="align: center"]0.0[/TD]
[TD="align: center"]0.0[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]8[/TD]

[TD="align: center"]501.2[/TD]

[TD="align: center"]497.81[/TD]
[TD="align: center"]-497.81[/TD]
[TD="align: center"]0.0[/TD]
[TD="align: center"]0.0[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]9[/TD]

[TD="align: center"]501.4[/TD]

[TD="align: center"]498.01[/TD]
[TD="align: center"]-498.01[/TD]
[TD="align: center"]0.0[/TD]
[TD="align: center"]0.0[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]10[/TD]

[TD="align: center"]501.6[/TD]

[TD="align: center"]498.21[/TD]
[TD="align: center"]-498.21[/TD]
[TD="align: center"]0.0[/TD]
[TD="align: center"]0.0[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]11[/TD]

[TD="align: center"]501.8[/TD]

[TD="align: center"]498.41[/TD]
[TD="align: center"]-498.41[/TD]
[TD="align: center"]0.0[/TD]
[TD="align: center"]0.0[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]12[/TD]

[TD="align: center"]502.0[/TD]

[TD="align: center"]498.61[/TD]
[TD="align: center"]-498.61[/TD]
[TD="align: center"]0.0[/TD]
[TD="align: center"]0.0[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]13[/TD]

[TD="align: center"]502.2[/TD]

[TD="align: center"]498.80[/TD]
[TD="align: center"]-498.80[/TD]
[TD="align: center"]0.0[/TD]
[TD="align: center"]0.0[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]14[/TD]

[TD="align: center"]502.4[/TD]

[TD="align: center"]499.00[/TD]
[TD="align: center"]-499.00[/TD]
[TD="align: center"]0.0[/TD]
[TD="align: center"]0.0[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]15[/TD]

[TD="align: center"]502.6[/TD]

[TD="align: center"]499.20[/TD]
[TD="align: center"]-499.20[/TD]
[TD="align: center"]0.0[/TD]
[TD="align: center"]0.0[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]16[/TD]

[TD="align: center"]502.8[/TD]

[TD="align: center"]499.40[/TD]
[TD="align: center"]-499.40[/TD]
[TD="align: center"]0.0[/TD]
[TD="align: center"]0.0[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]17[/TD]

[TD="align: center"]503.0[/TD]

[TD="align: center"]499.60[/TD]
[TD="align: center"]-499.60[/TD]
[TD="align: center"]0.0[/TD]
[TD="align: center"]0.0[/TD]

</tbody>


I'd like to automate this process as much as possible. This data comes from drilling oil wells and is depth based so the depth keeps increasing and new ROP, Gas and Gamma data is generated every 0.2 meters. The ROP-Gas.txt and gamma.las files are periodically overwritten in their folder keeping the file name the same but containing new depth based data. When that happens I'd like to automatically import these new values into the ROPdata sheet and have the ROP, Gas and Gamma data put into the cells with the matching Depth values.

I hope that I've explained what I'd like to do clearly - any help would be greatly appreciated.
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Forum statistics

Threads
1,223,889
Messages
6,175,226
Members
452,620
Latest member
dsubash

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