Logic in VBA to copy data from text file to Specific cell Address of worksheet

kcgmani2004

New Member
Joined
Feb 18, 2015
Messages
1

<tbody>
[TD="class: votecell"][/TD]
[TD="class: postcell"]I have text file which has data mentioned below format
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;"> "$B$6|9020541.78113024"
"$C$6|91873471.2672928"
"$D$6|596376192.52119"
"$E$6|697270205.569613" </code>Delimiters is "|" The first half before the delimiter is the Cell Address (Say B6) and the second half is the value which has to be copied over the workbook to a specific sheet(Say worksheet1)
I have already accomplished of loading the text file and read the content by looping but couldnt progress.
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;"> Open SplitTxtFile For Input As # 1

Do Until EOF ( 1 )
Line Input
# 1 , FileLine
Dim SplitFileLine As Variant
Dim newFileLine As String

newFileLine
= Replace ( FileLine , Chr ( 34 ), "" )
SplitFileLine
= Split ( newFileLine , "|" ) ' This split doesnt work </code><code style="margin: 0px; padding: 1px 5px; border: 0px; font-size: 13px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: pre-wrap; background-color: rgb(238, 238, 238);">'The data to be split and copy the value in appropriate cell address in the worksheet(ws1</code>)
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;"> Loop

Close
# 1
Please help to progress further. Ignore the text file read portion which is already accomplished by reading the directory.
</code>
[/TD]

</tbody>
 
Last edited:

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

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