Jump to content
lampel

New line in an excel cell

Recommended Posts

lampel

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
water

Replace @CRLF with Chr(10).


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
lampel

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
water

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 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
lampel

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
water

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


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
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

×