PC Review


Reply
Thread Tools Rate Thread

cell is merged and contains "something"

 
 
Carrie_Loos via OfficeKB.com
Guest
Posts: n/a
 
      17th Jan 2008
I am having trouble with this piece of code. I can't seem to make these two
variable work together. If I remove the "And Like "*me*" portion of the If
statement then the code will change the color correctly in the merged cells
but I can't seem to get the 'And' piece to work. Can anyone help?

Sub Customer_Colors()

For Each c In Range("B8:IT500")

If c.MergeCells = True And c.MergeCells Like "*something*" Then
c.Interior.ColorIndex = 4

Next

End Sub

Thanks
Carrie

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200801/1

 
Reply With Quote
 
 
 
 
Per Jessen
Guest
Posts: n/a
 
      17th Jan 2008
On 18 Jan., 00:20, "Carrie_Loos via OfficeKB.com" <u34134@uwe> wrote:
> I am having trouble with this piece of code. I can't seem to make these two
> variable work together. If I remove the "And Like "*me*" portion of the If
> statement then the code will change the color correctly in the merged cells
> but I can't seem to get the 'And' piece to work. Can anyone help?
>
> Sub Customer_Colors()
>
> For Each c In Range("B8:IT500")
>
> If c.MergeCells = True And c.MergeCells Like "*something*" Then
> * * c.Interior.ColorIndex = 4
>
> Next
>
> End Sub
>
> Thanks
> Carrie
>
> --
> Message posted via OfficeKB.comhttp://www.officekb.com/Uwe/Forums.aspx/excel-programming/200801/1


Hi Carrie

Try this

Sub Customer_Colors()
For Each c In Range("B7:IT50")
If c.MergeCells = True And c.Value Like "*something*" Then
c.Interior.ColorIndex = 4
Next
End Sub

Regards,

Per
 
Reply With Quote
 
Carrie_Loos via OfficeKB.com
Guest
Posts: n/a
 
      18th Jan 2008
I am still having the same issue - any other ideas?

Per Jessen wrote:
>> I am having trouble with this piece of code. I can't seem to make these two
>> variable work together. If I remove the "And Like "*me*" portion of the If

>[quoted text clipped - 17 lines]
>> --
>> Message posted via OfficeKB.comhttp://www.officekb.com/Uwe/Forums.aspx/excel-programming/200801/1

>
>Hi Carrie
>
>Try this
>
>Sub Customer_Colors()
>For Each c In Range("B7:IT50")
>If c.MergeCells = True And c.Value Like "*something*" Then
>c.Interior.ColorIndex = 4
>Next
>End Sub
>
>Regards,
>
>Per


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200801/1

 
Reply With Quote
 
Carrie_Loos via OfficeKB.com
Guest
Posts: n/a
 
      18th Jan 2008
My mistake, works well. Thanks

Per Jessen wrote:
>> I am having trouble with this piece of code. I can't seem to make these two
>> variable work together. If I remove the "And Like "*me*" portion of the If

>[quoted text clipped - 17 lines]
>> --
>> Message posted via OfficeKB.comhttp://www.officekb.com/Uwe/Forums.aspx/excel-programming/200801/1

>
>Hi Carrie
>
>Try this
>
>Sub Customer_Colors()
>For Each c In Range("B7:IT50")
>If c.MergeCells = True And c.Value Like "*something*" Then
>c.Interior.ColorIndex = 4
>Next
>End Sub
>
>Regards,
>
>Per


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200801/1

 
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
How to find non-blank cell values "hidden" under merged regions? david.karr Microsoft Excel Misc 7 7th Apr 2007 11:35 PM
"Cannot change part of a merged cell" when AutoFilter is turned on relative_virtue@hotmail.com Microsoft Excel Programming 0 14th Mar 2007 05:31 PM
"Cannot change part of merged cell" =?Utf-8?B?RXhjZWxIZWxwTmVlZGVk?= Microsoft Excel Discussion 1 6th Jul 2006 06:33 PM
"Cannot Change Part of a Merged Cell" When updating link using mac =?Utf-8?B?TWFkaGF2YQ==?= Microsoft Excel Programming 1 25th Oct 2005 10:14 AM
Help with getting text from "Merged Cell" tjhorne Microsoft Excel Worksheet Functions 6 6th Oct 2005 09:17 PM


Features
 

Advertising
 

Newsgroups
 


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