I have a spreadsheet that contains data that has to be put on a Notepad, but the spacing never lines up right. I have tried using text padding but am unable to figure out how to space this out. I want the users to be able to enter the information then just be able to copy and paste over to Notepad without spending hours making the information line-up to the headers. Any help is appreciated. I uploaded a picture of what happens when
it transfers to Notepad.
5 Answers
Without VBA one option will be as below:
Set up a table like below.
A B C D
20 15 15 15
Date / Time Type ID Duration Output
3/25/2018 13:49 Outgoing 1234567890 32s Formula Here
In Row 1, set the widths as you need and then in "Formula Here" place following formula:
=CONCATENATE(IF(A3="",REPT(" ",$A$1),REPLACE(REPT(" ",$A$1),1,LEN(TEXT(A3,"dd/mm/yyyy hh:mm")),TEXT(A3,"dd/mm/yyyy hh:mm")),REPLACE(REPT(" ",$B$1),1,LEN(B3),B3),REPLACE(REPT(" ",$C$1),1,LEN(C3),C3),REPLACE(REPT(" ",$D$1),1,LEN(D3),D3))
You can then copy this column and paste to Notepad as and when needed.
-
-
You can add an IF condition to column A to only pass the white space if the field is empty.– Eliot KMar 25, 2018 at 21:51
Assuming you don’t have to worry about line breaks in any of the columns, a simplistic recommendation would be to set up another sheet/tab with a formula like this:
={TEXTJOIN(“ “, FALSE, ‘SHEET1’!A2 & REPT(“ “, MAX(LEN(‘SHEET1’!A:A))), ‘SHEET1’!B2 & REPT(“ “, MAX(LEN(‘SHEET1’!B:B))), ... ‘SHEET1’!X2 & REPT(“ “, MAX(LEN(‘SHEET1’!X:X))))}
You should replace the ‘...’ and references to something appropriate. People could then copy from the this tab. This formula would have to be included for each row in the other spreadsheet. This can also be improved with VBA.
If you're creating the excel file then the easiest option would be to offer an alternative export in txt format.
The not so beautiful alternative would be to get the lenght of of the longest value (in chars) and add the missing amount of spaces behind the other values. However I didn't check whether excel trima vales when copying.
In both cases you won't have perfect alignment if the editor used to open the data uses a font that is not monospaced.
CSV might be an alternative (as it can be opened by both text editors and cell file editors)
The solution you opt for may vary depending on the environment your file is used.
But if you want your users to enter the data manually as stated in your question you might want to use VBA and offer an export button that allows users to create a txt file from excel.
Seems like you just have the spreadsheet set up inefficiently.
Instead of having a separate column for the different types, just have a column called "Type" and another called "ID", and never leave any cells blank, e.g. something like:
Date/Time Type ID etc...
1/1/18 Outgoing 1234567890
1/2/18 Incoming 1234567890
Another option is to save the file as a .csv file type (comma-separated value), then when you open in notepad, the entries are all separated by commas, and you can easily go back and forth between Excel and Notepad.
Another option is to save your spreadsheet as Formatted Text (Space delimited)( *.prn). You may have to add extra empty columns in between your columns to get it just how you want it but it works great for me. Then just open your *.prn file in notepad and you are good to go.
delimiter
. You can think of it like Excel inserting atab
for each vertical line (i.e. cell boundary) in your row. So a row in Excel that isA | B | C
becomesA<tab>B<tab>C
. Now as you might know from using Word, tabs have a fixed width, so if your text changes in length the tab will "ratchet" one further back or forth. You can avoid this by formatting your text appropriately (e.g. always using the fixed-lengthYYYY-MM-DD hh:mm
for dates).