cell is merged and contains "something"

  • Thread starter Thread starter Carrie_Loos via OfficeKB.com
  • Start date Start date
C

Carrie_Loos via OfficeKB.com

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
 
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

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
 
I am still having the same issue - any other ideas?

Per said:
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]
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
 
My mistake, works well. Thanks

Per said:
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]
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top