ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   cell is merged and contains "something" (https://www.excelbanter.com/excel-programming/404502-cell-merged-contains-something.html)

Carrie_Loos via OfficeKB.com

cell is merged and contains "something"
 
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


Per Jessen[_2_]

cell is merged and contains "something"
 
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

Carrie_Loos via OfficeKB.com

cell is merged and contains "something"
 
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


Carrie_Loos via OfficeKB.com

cell is merged and contains "something"
 
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



All times are GMT +1. The time now is 05:53 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com