strip last 3 characters from a txt file

SandsB

Well-known Member
Joined
Feb 13, 2007
Messages
705
Office Version
  1. 365
Platform
  1. Windows
I need to mechanize a process to monitor one of our systems. I need something that will read a text file every minute and strip off the last 3 characters of the 6th line of text and put it in a text file with some other text.
So if the 6th line of text is:
7 100 1 0 0 0 741
I'd copy the 741 into a text file that says only:
Curent Load is 741

The last 3 characters my start with a space like " 41"
The text file needs to be completely overwritten every minute. I can use a scheduler to run somethign to do that. I just have no clue how to get that little string into a text file. I'm sure it's possible with Excel but I'm stumped. If anybody knows a non-Excel way to do it I'd appreciate that too. I have no money to buy any tools, though. Thanks
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
A formula such as
Code:
=right(a6,3)
would capture the last 3 digits.

This assumes your text file is dumping everything into Col A of a spreadsheet, and the required value is on row 6, as you say.

I don't know how you'd do the automation though.
 
Upvote 0
there is a formula in excel

=Left(A6, Len(A6) -3)

This would leave everything but the last 3 characters

There is some similar VBA

Code:
Range("A6").Value = Left(Range("A6"), Len(Range("A6") - 3)

Does this give you anything to start with.
 
Upvote 0
But how do I create something I can startup and run every minute? I know how to use the Windows Scheduler so I can kick off something every minute but how to I start Excel in a way that a command like that would run?
 
Upvote 0

Forum statistics

Threads
1,214,652
Messages
6,120,746
Members
448,989
Latest member
mariah3

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