lampel

New line in an excel cell

6 posts in this topic

Hello all,

i have a single excel cell with A very long string in it , ex: "C1 C2 C3 C4 C5 C6 C7 ..............C2000" 

i want to start a new line within the same cell every 20 "CXX"

i have tried using:

For $i=1 to $stringLength
_StringInsert($MyString,@CRLF,20*$i)
Next

but @CRLF is entered as a string and not as a command.

i know its a beginner question and i have searched for an answer and could not find one.

Thanks lampel.

 

 

Share this post


Link to post
Share on other sites



Replace @CRLF with Chr(10).


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

thank you Water its working.

small follow up question :

how can i detect where to insert the new line so it wont break the line in the middle of the "CXX"

ex : "c1 c2 c3 c4 c5 c6" ----> "c1 c2 c3 Chr(10) c4 c5 c6"  (GOOD)

       "c1 c2 c3 c4 c5 c6" ----->"c1 c2 cChr(10)3 c4 c5 c6" (BAD)

Share this post


Link to post
Share on other sites

This should give you an idea:

$iMaxlen = 10
$sString = "c1 c2 c3 c4 c5 c6"
$sString = StringReplace(StringLeft($sString, $iMaxLen), " ", Chr(10), -1) & StringMid($sString, $iMaxLen + 1)
ConsoleWrite($sString & @CRLF)

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

hi water ,

That's not just an idea that's the whole solution thank u so much ! :)

The things you do in sec takes me like few hours ....

Share this post


Link to post
Share on other sites

The longer you use AutoIt the better and faster you will get :)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now