Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 158
Default Conditional formatting on autoshapes

Dear experts,

Jacob Skaria, MVP wrote me a marco below for the solution of conditional
formatting on autoshapes. As Jacob's macro refers the value of A1 to the
default name of the autoshapes, such as: the value of A1 = 2, then the
autoshape named "Oval 2" will be changed to colour green. However, I want the
value of A1 refers to the text inside Oval 2 instead, such as: value A1 =
table and the text inside Oval 2 = table, then autoshpae Oval 2 will turn
into colour green. How can I get it done? Please kindly advise.

Thanks in advance.

QUOTE

Private Sub Worksheet_Change(ByVal Target As Range)
Dim sh As Shape, intCount As Integer
If Not Application.Intersect(Target, Range("A1")) Is Nothing Then
For intCount = 1 To 10
On Error Resume Next
Set sh = ActiveSheet.Shapes("Oval " & intCount)
If Not sh Is Nothing Then
With sh
..Fill.Visible = msoTrue
..Fill.Solid
..Fill.ForeColor.SchemeColor = IIf(intCount = Target, 17, 1)
End With
ActiveSheet.DrawingObjects("Oval " & intCount).Text = "Hi" & intCount
ActiveSheet.DrawingObjects("Oval " & intCount).Font.ColorIndex = _
IIf(intCount = Target, 2, xlAutomatic)
ActiveSheet.DrawingObjects("Oval " & intCount).Font.Bold = (intCount =
Target)
End If
Set sh = Nothing
Next
End If
End Sub

UNQUOTE
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,441
Default Conditional formatting on autoshapes

Freshman,

You can loop through the shapes looking for the text: this version will only show the fill of the
shape with the matching text,

Private Sub Worksheet_Change(ByVal target As Range)
Dim sh As Shape

If target.Address < "$A$1" Then Exit Sub

For Each sh In ActiveSheet.Shapes
If sh.TextFrame.Characters.Text = target.Value Then
With sh
.Fill.Visible = msoTrue
.Fill.Solid
.Fill.ForeColor.SchemeColor = 17
End With
Else
sh.Fill.Visible = msoFalse
End If
Next sh

End Sub



HTH,
Bernie
MS Excel MVP


"Freshman" wrote in message
...
Dear experts,

Jacob Skaria, MVP wrote me a marco below for the solution of conditional
formatting on autoshapes. As Jacob's macro refers the value of A1 to the
default name of the autoshapes, such as: the value of A1 = 2, then the
autoshape named "Oval 2" will be changed to colour green. However, I want the
value of A1 refers to the text inside Oval 2 instead, such as: value A1 =
table and the text inside Oval 2 = table, then autoshpae Oval 2 will turn
into colour green. How can I get it done? Please kindly advise.

Thanks in advance.

QUOTE

Private Sub Worksheet_Change(ByVal Target As Range)
Dim sh As Shape, intCount As Integer
If Not Application.Intersect(Target, Range("A1")) Is Nothing Then
For intCount = 1 To 10
On Error Resume Next
Set sh = ActiveSheet.Shapes("Oval " & intCount)
If Not sh Is Nothing Then
With sh
.Fill.Visible = msoTrue
.Fill.Solid
.Fill.ForeColor.SchemeColor = IIf(intCount = Target, 17, 1)
End With
ActiveSheet.DrawingObjects("Oval " & intCount).Text = "Hi" & intCount
ActiveSheet.DrawingObjects("Oval " & intCount).Font.ColorIndex = _
IIf(intCount = Target, 2, xlAutomatic)
ActiveSheet.DrawingObjects("Oval " & intCount).Font.Bold = (intCount =
Target)
End If
Set sh = Nothing
Next
End If
End Sub

UNQUOTE



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,520
Default Conditional formatting on autoshapes

Hi again

In the first place I am not an MVP; but just another contributor.

Try the below...which will look out for any shapes and if the text matches
will format as required.


Private Sub Worksheet_Change(ByVal Target As Range)
Dim sh As Shape, intComp As Integer
If Not Application.Intersect(Target, Range("A1")) Is Nothing Then
For Each sh In ActiveSheet.Shapes
intComp = StrComp(sh.TextFrame.Characters.Text, Target.Text, vbTextCompare)
With sh
..TextFrame.Characters.Font.Bold = (intComp = 0)
..TextFrame.Characters.Font.ColorIndex = IIf(intComp, xlAutomatic, 2)
..Fill.ForeColor.SchemeColor = IIf(intComp, 1, 17)
End With
Next
End If
End Sub


If this post helps click Yes
---------------
Jacob Skaria


"Freshman" wrote:

Dear experts,

Jacob Skaria, MVP wrote me a marco below for the solution of conditional
formatting on autoshapes. As Jacob's macro refers the value of A1 to the
default name of the autoshapes, such as: the value of A1 = 2, then the
autoshape named "Oval 2" will be changed to colour green. However, I want the
value of A1 refers to the text inside Oval 2 instead, such as: value A1 =
table and the text inside Oval 2 = table, then autoshpae Oval 2 will turn
into colour green. How can I get it done? Please kindly advise.

Thanks in advance.

QUOTE

Private Sub Worksheet_Change(ByVal Target As Range)
Dim sh As Shape, intCount As Integer
If Not Application.Intersect(Target, Range("A1")) Is Nothing Then
For intCount = 1 To 10
On Error Resume Next
Set sh = ActiveSheet.Shapes("Oval " & intCount)
If Not sh Is Nothing Then
With sh
.Fill.Visible = msoTrue
.Fill.Solid
.Fill.ForeColor.SchemeColor = IIf(intCount = Target, 17, 1)
End With
ActiveSheet.DrawingObjects("Oval " & intCount).Text = "Hi" & intCount
ActiveSheet.DrawingObjects("Oval " & intCount).Font.ColorIndex = _
IIf(intCount = Target, 2, xlAutomatic)
ActiveSheet.DrawingObjects("Oval " & intCount).Font.Bold = (intCount =
Target)
End If
Set sh = Nothing
Next
End If
End Sub

UNQUOTE

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 158
Default Conditional formatting on autoshapes

Hi Bernie,

Thanks for your tips. What about if I input numbers into the autoshapes
instead of text. How you change the macro? Please kindly advise.

Thanks a million.

"Bernie Deitrick" wrote:

Freshman,

You can loop through the shapes looking for the text: this version will only show the fill of the
shape with the matching text,

Private Sub Worksheet_Change(ByVal target As Range)
Dim sh As Shape

If target.Address < "$A$1" Then Exit Sub

For Each sh In ActiveSheet.Shapes
If sh.TextFrame.Characters.Text = target.Value Then
With sh
.Fill.Visible = msoTrue
.Fill.Solid
.Fill.ForeColor.SchemeColor = 17
End With
Else
sh.Fill.Visible = msoFalse
End If
Next sh

End Sub



HTH,
Bernie
MS Excel MVP


"Freshman" wrote in message
...
Dear experts,

Jacob Skaria, MVP wrote me a marco below for the solution of conditional
formatting on autoshapes. As Jacob's macro refers the value of A1 to the
default name of the autoshapes, such as: the value of A1 = 2, then the
autoshape named "Oval 2" will be changed to colour green. However, I want the
value of A1 refers to the text inside Oval 2 instead, such as: value A1 =
table and the text inside Oval 2 = table, then autoshpae Oval 2 will turn
into colour green. How can I get it done? Please kindly advise.

Thanks in advance.

QUOTE

Private Sub Worksheet_Change(ByVal Target As Range)
Dim sh As Shape, intCount As Integer
If Not Application.Intersect(Target, Range("A1")) Is Nothing Then
For intCount = 1 To 10
On Error Resume Next
Set sh = ActiveSheet.Shapes("Oval " & intCount)
If Not sh Is Nothing Then
With sh
.Fill.Visible = msoTrue
.Fill.Solid
.Fill.ForeColor.SchemeColor = IIf(intCount = Target, 17, 1)
End With
ActiveSheet.DrawingObjects("Oval " & intCount).Text = "Hi" & intCount
ActiveSheet.DrawingObjects("Oval " & intCount).Font.ColorIndex = _
IIf(intCount = Target, 2, xlAutomatic)
ActiveSheet.DrawingObjects("Oval " & intCount).Font.Bold = (intCount =
Target)
End If
Set sh = Nothing
Next
End If
End Sub

UNQUOTE



.

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,441
Default Conditional formatting on autoshapes

The autoshapes always have text. You could try this - change

If sh.TextFrame.Characters.Text = target.Value Then

to

If sh.TextFrame.Characters.Text = CStr(target.Value) Then

You could also format your target cell as string.

HTH,
Bernie
MS Excel MVP


"Freshman" wrote in message
...
Hi Bernie,

Thanks for your tips. What about if I input numbers into the autoshapes
instead of text. How you change the macro? Please kindly advise.

Thanks a million.

"Bernie Deitrick" wrote:

Freshman,

You can loop through the shapes looking for the text: this version will
only show the fill of the
shape with the matching text,

Private Sub Worksheet_Change(ByVal target As Range)
Dim sh As Shape

If target.Address < "$A$1" Then Exit Sub

For Each sh In ActiveSheet.Shapes
If sh.TextFrame.Characters.Text = target.Value Then
With sh
.Fill.Visible = msoTrue
.Fill.Solid
.Fill.ForeColor.SchemeColor = 17
End With
Else
sh.Fill.Visible = msoFalse
End If
Next sh

End Sub



HTH,
Bernie
MS Excel MVP


"Freshman" wrote in message
...
Dear experts,

Jacob Skaria, MVP wrote me a marco below for the solution of
conditional
formatting on autoshapes. As Jacob's macro refers the value of A1 to
the
default name of the autoshapes, such as: the value of A1 = 2, then the
autoshape named "Oval 2" will be changed to colour green. However, I
want the
value of A1 refers to the text inside Oval 2 instead, such as: value A1
=
table and the text inside Oval 2 = table, then autoshpae Oval 2 will
turn
into colour green. How can I get it done? Please kindly advise.

Thanks in advance.

QUOTE

Private Sub Worksheet_Change(ByVal Target As Range)
Dim sh As Shape, intCount As Integer
If Not Application.Intersect(Target, Range("A1")) Is Nothing Then
For intCount = 1 To 10
On Error Resume Next
Set sh = ActiveSheet.Shapes("Oval " & intCount)
If Not sh Is Nothing Then
With sh
.Fill.Visible = msoTrue
.Fill.Solid
.Fill.ForeColor.SchemeColor = IIf(intCount = Target, 17, 1)
End With
ActiveSheet.DrawingObjects("Oval " & intCount).Text = "Hi" & intCount
ActiveSheet.DrawingObjects("Oval " & intCount).Font.ColorIndex = _
IIf(intCount = Target, 2, xlAutomatic)
ActiveSheet.DrawingObjects("Oval " & intCount).Font.Bold = (intCount =
Target)
End If
Set sh = Nothing
Next
End If
End Sub

UNQUOTE



.




  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 158
Default Conditional formatting on autoshapes

Hi Bernie,

Sorry to bother you. I found a dialogue box "Runtime error 13, Type
mismatch" even I change the macro statement you teach me. Is there a way to
correct?

Thanks in advance.

"Bernie Deitrick" wrote:

The autoshapes always have text. You could try this - change

If sh.TextFrame.Characters.Text = target.Value Then

to

If sh.TextFrame.Characters.Text = CStr(target.Value) Then

You could also format your target cell as string.

HTH,
Bernie
MS Excel MVP


"Freshman" wrote in message
...
Hi Bernie,

Thanks for your tips. What about if I input numbers into the autoshapes
instead of text. How you change the macro? Please kindly advise.

Thanks a million.

"Bernie Deitrick" wrote:

Freshman,

You can loop through the shapes looking for the text: this version will
only show the fill of the
shape with the matching text,

Private Sub Worksheet_Change(ByVal target As Range)
Dim sh As Shape

If target.Address < "$A$1" Then Exit Sub

For Each sh In ActiveSheet.Shapes
If sh.TextFrame.Characters.Text = target.Value Then
With sh
.Fill.Visible = msoTrue
.Fill.Solid
.Fill.ForeColor.SchemeColor = 17
End With
Else
sh.Fill.Visible = msoFalse
End If
Next sh

End Sub



HTH,
Bernie
MS Excel MVP


"Freshman" wrote in message
...
Dear experts,

Jacob Skaria, MVP wrote me a marco below for the solution of
conditional
formatting on autoshapes. As Jacob's macro refers the value of A1 to
the
default name of the autoshapes, such as: the value of A1 = 2, then the
autoshape named "Oval 2" will be changed to colour green. However, I
want the
value of A1 refers to the text inside Oval 2 instead, such as: value A1
=
table and the text inside Oval 2 = table, then autoshpae Oval 2 will
turn
into colour green. How can I get it done? Please kindly advise.

Thanks in advance.

QUOTE

Private Sub Worksheet_Change(ByVal Target As Range)
Dim sh As Shape, intCount As Integer
If Not Application.Intersect(Target, Range("A1")) Is Nothing Then
For intCount = 1 To 10
On Error Resume Next
Set sh = ActiveSheet.Shapes("Oval " & intCount)
If Not sh Is Nothing Then
With sh
.Fill.Visible = msoTrue
.Fill.Solid
.Fill.ForeColor.SchemeColor = IIf(intCount = Target, 17, 1)
End With
ActiveSheet.DrawingObjects("Oval " & intCount).Text = "Hi" & intCount
ActiveSheet.DrawingObjects("Oval " & intCount).Font.ColorIndex = _
IIf(intCount = Target, 2, xlAutomatic)
ActiveSheet.DrawingObjects("Oval " & intCount).Font.Bold = (intCount =
Target)
End If
Set sh = Nothing
Next
End If
End Sub

UNQUOTE


.


.

  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,441
Default Conditional formatting on autoshapes

Freshman,

I cannot get that error. What is the format of cell A1, and what value or text are you using?
Could you also post all of your code - perhaps that is the source of the error.

HTH,
Bernie
MS Excel MVP


"Freshman" wrote in message
...
Hi Bernie,

Sorry to bother you. I found a dialogue box "Runtime error 13, Type
mismatch" even I change the macro statement you teach me. Is there a way to
correct?



  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 158
Default Conditional formatting on autoshapes

Hi Bernie,

The code below is exactly the same (I just copy and paste) you wrote me
before. The format in A1, no matter I set it as "General", "Number" or
"Text", the same error message appeared.

Sorry to bother you. Thanks.

Private Sub Worksheet_Change(ByVal target As Range)
Dim sh As Shape

If target.Address < "$A$1" Then Exit Sub

For Each sh In ActiveSheet.Shapes
If sh.TextFrame.Characters.Text = target.Value Then
With sh
..Fill.Visible = msoTrue
..Fill.Solid
..Fill.ForeColor.SchemeColor = 17
End With
Else
sh.Fill.Visible = msoFalse
End If
Next sh

End Sub

"Bernie Deitrick" wrote:

Freshman,

I cannot get that error. What is the format of cell A1, and what value or text are you using?
Could you also post all of your code - perhaps that is the source of the error.

HTH,
Bernie
MS Excel MVP


"Freshman" wrote in message
...
Hi Bernie,

Sorry to bother you. I found a dialogue box "Runtime error 13, Type
mismatch" even I change the macro statement you teach me. Is there a way to
correct?



.

  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 158
Default Conditional formatting on autoshapes

Hi Bernie,

Forget to write what the text I put inside the auotshpaes. It is simply the
numbers, such as 1, 2, 5, 60, 72 etc. I want if I input 1 into A1, then the
autoshape contains the text "1" will turn to green colour.

Thanks.

"Bernie Deitrick" wrote:

Freshman,

I cannot get that error. What is the format of cell A1, and what value or text are you using?
Could you also post all of your code - perhaps that is the source of the error.

HTH,
Bernie
MS Excel MVP


"Freshman" wrote in message
...
Hi Bernie,

Sorry to bother you. I found a dialogue box "Runtime error 13, Type
mismatch" even I change the macro statement you teach me. Is there a way to
correct?



.

  #10   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,441
Default Conditional formatting on autoshapes

Freshman,

Contact me privately - make the obvious changes to my email address when you reply - and I will send
you a working version.

HTH,
Bernie
MS Excel MVP


"Freshman" wrote in message
...
Hi Bernie,

Forget to write what the text I put inside the auotshpaes. It is simply the
numbers, such as 1, 2, 5, 60, 72 etc. I want if I input 1 into A1, then the
autoshape contains the text "1" will turn to green colour.

Thanks.

"Bernie Deitrick" wrote:

Freshman,

I cannot get that error. What is the format of cell A1, and what value or text are you using?
Could you also post all of your code - perhaps that is the source of the error.

HTH,
Bernie
MS Excel MVP


"Freshman" wrote in message
...
Hi Bernie,

Sorry to bother you. I found a dialogue box "Runtime error 13, Type
mismatch" even I change the macro statement you teach me. Is there a way to
correct?



.





  #11   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 158
Default Conditional formatting on autoshapes

Hi Bernie,

Can you give me your email address so that I can send the file to you? Many
thanks.

"Bernie Deitrick" wrote:

Freshman,

Contact me privately - make the obvious changes to my email address when you reply - and I will send
you a working version.

HTH,
Bernie
MS Excel MVP


"Freshman" wrote in message
...
Hi Bernie,

Forget to write what the text I put inside the auotshpaes. It is simply the
numbers, such as 1, 2, 5, 60, 72 etc. I want if I input 1 into A1, then the
autoshape contains the text "1" will turn to green colour.

Thanks.

"Bernie Deitrick" wrote:

Freshman,

I cannot get that error. What is the format of cell A1, and what value or text are you using?
Could you also post all of your code - perhaps that is the source of the error.

HTH,
Bernie
MS Excel MVP


"Freshman" wrote in message
...
Hi Bernie,

Sorry to bother you. I found a dialogue box "Runtime error 13, Type
mismatch" even I change the macro statement you teach me. Is there a way to
correct?



.



.

  #12   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,441
Default Conditional formatting on autoshapes

deitbe @ consumer dot org


HTH,
Bernie
MS Excel MVP


"Freshman" wrote in message
...
Hi Bernie,

Can you give me your email address so that I can send the file to you? Many
thanks.



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
Formatting cells in a column with conditional formatting? shamor Excel Discussion (Misc queries) 8 May 19th 08 10:11 PM
Protect Cell Formatting including Conditional Formatting Mick Jennings Excel Discussion (Misc queries) 5 November 13th 07 05:32 PM
Formatting multiple spreadsheets using Autoshapes Fuel Cells for the Future[_2_] Excel Discussion (Misc queries) 2 October 11th 07 05:37 PM
Conditional Formatting that will display conditional data BrainFart Excel Worksheet Functions 1 September 13th 05 05:45 PM
conditional formatting autoshapes [email protected] Excel Worksheet Functions 2 September 13th 05 10:50 AM


All times are GMT +1. The time now is 12:44 AM.

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

About Us

"It's about Microsoft Excel"