strip last 3 characters from a txt file

SandsB

Well-known Member
Joined
Feb 13, 2007
Messages
634
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

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Gerald Higgins

Well-known Member
Joined
Mar 26, 2007
Messages
9,194
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.
 

brian.wethington

Well-known Member
Joined
Jul 20, 2006
Messages
1,739
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.
 

SandsB

Well-known Member
Joined
Feb 13, 2007
Messages
634
Office Version
  1. 365
Platform
  1. Windows
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?
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,008
Messages
5,834,866
Members
430,324
Latest member
bosphoruskid

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
Top