Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 312
Default Wrap text in VBA

Hi all. I have a long formula in VBA:

ActiveCell.Formula = "=IF(ISBLANK(B" & cellrow & "),"""",IF(D" & cellrow &
"=""Yes"",LOWER(CONCATENATE(LEFT(B" & cellrow & ",1),RIGHT(B" & cellrow &
",LEN(B" & cellrow & ")-FIND("" "",B" & cellrow &
")))),LOWER(CONCATENATE(LEFT(B" & cellrow & ",1),""."",RIGHT(B" & cellrow &
",LEN(B" & cellrow & ")-FIND("" "",B" & cellrow & "))))))"


When I try to fo the "space underscore" to wrap the code down to the next
line, I get compile errors. Can I not use the _ to wrap text within a
formula?



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Wrap text in VBA

Yes, but you can't break string integrity.

Instead of

s = "abcd _
efgh"

you have to do

s= "abcd" _
& "efgh"

--
Regards,
Tom Ogilvy

"Steph" wrote in message
...
Hi all. I have a long formula in VBA:

ActiveCell.Formula = "=IF(ISBLANK(B" & cellrow & "),"""",IF(D" & cellrow

&
"=""Yes"",LOWER(CONCATENATE(LEFT(B" & cellrow & ",1),RIGHT(B" & cellrow &
",LEN(B" & cellrow & ")-FIND("" "",B" & cellrow &
")))),LOWER(CONCATENATE(LEFT(B" & cellrow & ",1),""."",RIGHT(B" & cellrow

&
",LEN(B" & cellrow & ")-FIND("" "",B" & cellrow & "))))))"


When I try to fo the "space underscore" to wrap the code down to the next
line, I get compile errors. Can I not use the _ to wrap text within a
formula?





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 312
Default Wrap text in VBA

Thanks Tom.

"Tom Ogilvy" wrote in message
...
Yes, but you can't break string integrity.

Instead of

s = "abcd _
efgh"

you have to do

s= "abcd" _
& "efgh"

--
Regards,
Tom Ogilvy

"Steph" wrote in message
...
Hi all. I have a long formula in VBA:

ActiveCell.Formula = "=IF(ISBLANK(B" & cellrow & "),"""",IF(D" &

cellrow
&
"=""Yes"",LOWER(CONCATENATE(LEFT(B" & cellrow & ",1),RIGHT(B" & cellrow

&
",LEN(B" & cellrow & ")-FIND("" "",B" & cellrow &
")))),LOWER(CONCATENATE(LEFT(B" & cellrow & ",1),""."",RIGHT(B" &

cellrow
&
",LEN(B" & cellrow & ")-FIND("" "",B" & cellrow & "))))))"


When I try to fo the "space underscore" to wrap the code down to the

next
line, I get compile errors. Can I not use the _ to wrap text within a
formula?







  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Wrap text in VBA


When entering functions/formulas thru VBA
it's often lots simpler (certainly when working
with relative references) to use R1C1.

(and ofcourse assign them to FormulaR1c1)

then you dont need the cellrow at all and
you can simply enter the formula.

rngDest.formular1c1= "=IF(ISBLANK(RC2),"""", etc




--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Steph wrote :

Thanks Tom.

"Tom Ogilvy" wrote in message
...
Yes, but you can't break string integrity.

Instead of

s = "abcd _
efgh"

you have to do

s= "abcd" _
& "efgh"

--
Regards,
Tom Ogilvy

"Steph" wrote in message
...
Hi all. I have a long formula in VBA:

ActiveCell.Formula = "=IF(ISBLANK(B" & cellrow & "),"""",IF(D" &

cellrow
&
"=""Yes"",LOWER(CONCATENATE(LEFT(B" & cellrow & ",1),RIGHT(B" &
cellrow

&
",LEN(B" & cellrow & ")-FIND("" "",B" & cellrow &
")))),LOWER(CONCATENATE(LEFT(B" & cellrow & ",1),""."",RIGHT(B" &

cellrow
&
",LEN(B" & cellrow & ")-FIND("" "",B" & cellrow & "))))))"


When I try to fo the "space underscore" to wrap the code down to
the

next
line, I get compile errors. Can I not use the _ to wrap text
within a formula?





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 312
Default Wrap text in VBA

Great suggestion - Thanks!

"keepITcool" wrote in message
ft.com...

When entering functions/formulas thru VBA
it's often lots simpler (certainly when working
with relative references) to use R1C1.

(and ofcourse assign them to FormulaR1c1)

then you dont need the cellrow at all and
you can simply enter the formula.

rngDest.formular1c1= "=IF(ISBLANK(RC2),"""", etc




--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Steph wrote :

Thanks Tom.

"Tom Ogilvy" wrote in message
...
Yes, but you can't break string integrity.

Instead of

s = "abcd _
efgh"

you have to do

s= "abcd" _
& "efgh"

--
Regards,
Tom Ogilvy

"Steph" wrote in message
...
Hi all. I have a long formula in VBA:

ActiveCell.Formula = "=IF(ISBLANK(B" & cellrow & "),"""",IF(D" &

cellrow
&
"=""Yes"",LOWER(CONCATENATE(LEFT(B" & cellrow & ",1),RIGHT(B" &
cellrow

&
",LEN(B" & cellrow & ")-FIND("" "",B" & cellrow &
")))),LOWER(CONCATENATE(LEFT(B" & cellrow & ",1),""."",RIGHT(B" &

cellrow
&
",LEN(B" & cellrow & ")-FIND("" "",B" & cellrow & "))))))"


When I try to fo the "space underscore" to wrap the code down to
the

next
line, I get compile errors. Can I not use the _ to wrap text
within a formula?







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I get date/time to wrap (format - wrap text doesn't work)? Alex Excel Discussion (Misc queries) 3 April 4th 23 02:29 PM
Excel 2007; even though "Wrap Text" is on the text does wrap? Bruce M[_2_] Excel Discussion (Misc queries) 0 December 31st 09 02:58 PM
Wrap text doesn't wrap [email protected] Excel Worksheet Functions 1 March 28th 07 01:58 AM
Why won't text in cell wrap. Cell format set to wrap. DRB Excel Discussion (Misc queries) 2 September 28th 06 08:27 PM
Text not continuing to wrap for large block of text in Excel cell Mandra Charts and Charting in Excel 1 May 15th 06 07:13 PM


All times are GMT +1. The time now is 01:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"