PC Review


Reply
Thread Tools Rate Thread

Concatenate Formula Using Nested IF(ISBLANK)

 
 
Sisilla
Guest
Posts: n/a
 
      18th Oct 2007
Hello All,

I am trying to concatenate the values of three cells and set the value
of the first cell to the result. The first cell is always non-empty.
If the second cell is non-empty, I concatenate a line break and its
value with the first cell. If the third cell is non-empty, I
concatenate a line break and its value with the value of the first
cell. The following For Loop runs very slowly-:

For Counter = 1 To LastRow
Set DoneBy = Worksheets("Data2").Cells(Counter, 5)
DoneBy = Worksheets("Data2").Cells(Counter, 5).Text
If Worksheets("Data2").Cells(Counter, 9).Text <> "" Then
DoneBy = DoneBy.Text & Chr(10) &
Worksheets("Data2").Cells(Counter, 9).Text
End If
If Worksheets("Data2").Cells(Counter, 13).Text <> "" Then
DoneBy = DoneBy.Text & Chr(10) &
Worksheets("Data2").Cells(Counter, 13).Text
End If
Next Counter

Is there a faster way to do this? The following code does not work -:

Sheets("Data2").Columns("F:F").Insert
Sheets("Data2").Range("F1:F" & LastRow).FormulaR1C1 = _
"=CONCATENATE(RC[-1], IF(ISBLANK(RC[4], """", CHAR(10)),_
RC[4], IF(ISBLANK(RC[8], """", CHAR(10)), RC[8]) "

I appreciate any effort to help me. Thank you for your time and
consideration.

Sincerely

Sisilla

 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      18th Oct 2007
This might be quicker

With Worksheets("Data2")
For Counter = 1 To LastRow
.Cells(Counter, 5).Value = .Cells(Counter, 5).Text & _
Chr(10) & .Cells(Counter, 9).Text & _
Chr(10) & .Cells(Counter, 13).Text
.Cells(Counter, 5).Value = Replace(.Cells(Counter, 5).Text, _
Chr(10) & Chr(10), Chr(10))
Next Counter
End With


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Sisilla" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello All,
>
> I am trying to concatenate the values of three cells and set the value
> of the first cell to the result. The first cell is always non-empty.
> If the second cell is non-empty, I concatenate a line break and its
> value with the first cell. If the third cell is non-empty, I
> concatenate a line break and its value with the value of the first
> cell. The following For Loop runs very slowly-:
>
> For Counter = 1 To LastRow
> Set DoneBy = Worksheets("Data2").Cells(Counter, 5)
> DoneBy = Worksheets("Data2").Cells(Counter, 5).Text
> If Worksheets("Data2").Cells(Counter, 9).Text <> "" Then
> DoneBy = DoneBy.Text & Chr(10) &
> Worksheets("Data2").Cells(Counter, 9).Text
> End If
> If Worksheets("Data2").Cells(Counter, 13).Text <> "" Then
> DoneBy = DoneBy.Text & Chr(10) &
> Worksheets("Data2").Cells(Counter, 13).Text
> End If
> Next Counter
>
> Is there a faster way to do this? The following code does not work -:
>
> Sheets("Data2").Columns("F:F").Insert
> Sheets("Data2").Range("F1:F" & LastRow).FormulaR1C1 = _
> "=CONCATENATE(RC[-1], IF(ISBLANK(RC[4], """", CHAR(10)),_
> RC[4], IF(ISBLANK(RC[8], """", CHAR(10)), RC[8]) "
>
> I appreciate any effort to help me. Thank you for your time and
> consideration.
>
> Sincerely
>
> Sisilla
>



 
Reply With Quote
 
Sisilla
Guest
Posts: n/a
 
      18th Oct 2007
On Oct 18, 9:35 am, "Bob Phillips" <bob....@somewhere.com> wrote:
> This might be quicker
>
> With Worksheets("Data2")
> For Counter = 1 To LastRow
> .Cells(Counter, 5).Value = .Cells(Counter, 5).Text & _
> Chr(10) & .Cells(Counter, 9).Text & _
> Chr(10) & .Cells(Counter, 13).Text
> .Cells(Counter, 5).Value = Replace(.Cells(Counter, 5).Text, _
> Chr(10) & Chr(10), Chr(10))
> Next Counter
> End With
>
> --
> HTH
>
> Bob
>
> (there's no email, no snail mail, but somewhere should be gmail in my addy)
>
> "Sisilla" <sisill...@gmail.com> wrote in message
>
> news:(E-Mail Removed)...
>
>
>
> > Hello All,

>
> > I am trying to concatenate the values of three cells and set the value
> > of the first cell to the result. The first cell is always non-empty.
> > If the second cell is non-empty, I concatenate a line break and its
> > value with the first cell. If the third cell is non-empty, I
> > concatenate a line break and its value with the value of the first
> > cell. The following For Loop runs very slowly-:

>
> > For Counter = 1 To LastRow
> > Set DoneBy = Worksheets("Data2").Cells(Counter, 5)
> > DoneBy = Worksheets("Data2").Cells(Counter, 5).Text
> > If Worksheets("Data2").Cells(Counter, 9).Text <> "" Then
> > DoneBy = DoneBy.Text & Chr(10) &
> > Worksheets("Data2").Cells(Counter, 9).Text
> > End If
> > If Worksheets("Data2").Cells(Counter, 13).Text <> "" Then
> > DoneBy = DoneBy.Text & Chr(10) &
> > Worksheets("Data2").Cells(Counter, 13).Text
> > End If
> > Next Counter

>
> > Is there a faster way to do this? The following code does not work -:

>
> > Sheets("Data2").Columns("F:F").Insert
> > Sheets("Data2").Range("F1:F" & LastRow).FormulaR1C1 = _
> > "=CONCATENATE(RC[-1], IF(ISBLANK(RC[4], """", CHAR(10)),_
> > RC[4], IF(ISBLANK(RC[8], """", CHAR(10)), RC[8]) "

>
> > I appreciate any effort to help me. Thank you for your time and
> > consideration.

>
> > Sincerely

>
> > Sisilla- Hide quoted text -

>
> - Show quoted text -


Thank you, Bob. Your code is a lot faster and a lot less messy as
well. Again, thanks! -Sisilla

 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      19th Oct 2007
Glad to hear that. I didn't have a way to really test it, so it was just
theory <bg>

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Sisilla" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Oct 18, 9:35 am, "Bob Phillips" <bob....@somewhere.com> wrote:
>> This might be quicker
>>
>> With Worksheets("Data2")
>> For Counter = 1 To LastRow
>> .Cells(Counter, 5).Value = .Cells(Counter, 5).Text & _
>> Chr(10) & .Cells(Counter, 9).Text & _
>> Chr(10) & .Cells(Counter, 13).Text
>> .Cells(Counter, 5).Value = Replace(.Cells(Counter, 5).Text, _
>> Chr(10) & Chr(10), Chr(10))
>> Next Counter
>> End With
>>
>> --
>> HTH
>>
>> Bob
>>
>> (there's no email, no snail mail, but somewhere should be gmail in my
>> addy)
>>
>> "Sisilla" <sisill...@gmail.com> wrote in message
>>
>> news:(E-Mail Removed)...
>>
>>
>>
>> > Hello All,

>>
>> > I am trying to concatenate the values of three cells and set the value
>> > of the first cell to the result. The first cell is always non-empty.
>> > If the second cell is non-empty, I concatenate a line break and its
>> > value with the first cell. If the third cell is non-empty, I
>> > concatenate a line break and its value with the value of the first
>> > cell. The following For Loop runs very slowly-:

>>
>> > For Counter = 1 To LastRow
>> > Set DoneBy = Worksheets("Data2").Cells(Counter, 5)
>> > DoneBy = Worksheets("Data2").Cells(Counter, 5).Text
>> > If Worksheets("Data2").Cells(Counter, 9).Text <> "" Then
>> > DoneBy = DoneBy.Text & Chr(10) &
>> > Worksheets("Data2").Cells(Counter, 9).Text
>> > End If
>> > If Worksheets("Data2").Cells(Counter, 13).Text <> "" Then
>> > DoneBy = DoneBy.Text & Chr(10) &
>> > Worksheets("Data2").Cells(Counter, 13).Text
>> > End If
>> > Next Counter

>>
>> > Is there a faster way to do this? The following code does not work -:

>>
>> > Sheets("Data2").Columns("F:F").Insert
>> > Sheets("Data2").Range("F1:F" & LastRow).FormulaR1C1 = _
>> > "=CONCATENATE(RC[-1], IF(ISBLANK(RC[4], """", CHAR(10)),_
>> > RC[4], IF(ISBLANK(RC[8], """", CHAR(10)), RC[8]) "

>>
>> > I appreciate any effort to help me. Thank you for your time and
>> > consideration.

>>
>> > Sincerely

>>
>> > Sisilla- Hide quoted text -

>>
>> - Show quoted text -

>
> Thank you, Bob. Your code is a lot faster and a lot less messy as
> well. Again, thanks! -Sisilla
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF/ISBLANK formula Missile Microsoft Excel New Users 3 24th Feb 2010 01:54 PM
if(and(isblank( formula help JC Microsoft Excel Worksheet Functions 2 22nd May 2008 11:25 PM
CONCATENATE with CHAR(10) IF NOT ISBLANK Sisilla Microsoft Excel Programming 2 18th Oct 2007 05:05 PM
CONCATENATE with CHAR(10) IF NOT ISBLANK Sisilla Microsoft Excel Programming 6 18th Oct 2007 07:10 AM
ISBLANK Formula Help =?Utf-8?B?cHRfbGlseQ==?= Microsoft Excel Misc 4 12th Jun 2007 04:40 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:24 AM.