Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Problem with cell value


Hello,
I got this code to work with the help of some of the experts from this
forum.
What is does is changes the color of a shape based on the value of a
cell. However, I've found that if I type 1 in the cell, the color
changes. If I type 0, the shape color changes like it should. The
problem is that when I put a formula in that cell that would return the
value of 1 or 0, nothing happens. I think this code is looking at the
formula, and not the value.

How do I alter this code so that I would respond to the cell value, and
not the formula. Or is there another code I could use.

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Me.Range("A1")) Is Nothing Then
With Me.Shapes(AutoShape1).Fill.ForeColor
Select Case Me.Range("A1").Value
Case 1: .SchemeColor = 2
Case 0: .SchemeColor = 12
Case Else: .SchemeColor = 11
End Select
End With
End If
End Sub

Thanks,
EMoe


--
EMoe
------------------------------------------------------------------------
EMoe's Profile: http://www.excelforum.com/member.php...o&userid=23183
View this thread: http://www.excelforum.com/showthread...hreadid=386218

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Problem with cell value

You need to use the Calculate event, not the Change event.

Private Sub Worksheet_Calculate()
With Me.Shapes(AutoShape1).Fill.ForeColor
Select Case Me.Range("A1").Value
Case 1: .SchemeColor = 2
Case 0: .SchemeColor = 12
Case Else: .SchemeColor = 11
End Select
End With
End Sub

--
Regards,
Tom Ogilvy


"EMoe" wrote in message
...

Hello,
I got this code to work with the help of some of the experts from this
forum.
What is does is changes the color of a shape based on the value of a
cell. However, I've found that if I type 1 in the cell, the color
changes. If I type 0, the shape color changes like it should. The
problem is that when I put a formula in that cell that would return the
value of 1 or 0, nothing happens. I think this code is looking at the
formula, and not the value.

How do I alter this code so that I would respond to the cell value, and
not the formula. Or is there another code I could use.

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Me.Range("A1")) Is Nothing Then
With Me.Shapes(AutoShape1).Fill.ForeColor
Select Case Me.Range("A1").Value
Case 1: .SchemeColor = 2
Case 0: .SchemeColor = 12
Case Else: .SchemeColor = 11
End Select
End With
End If
End Sub

Thanks,
EMoe


--
EMoe
------------------------------------------------------------------------
EMoe's Profile:

http://www.excelforum.com/member.php...o&userid=23183
View this thread: http://www.excelforum.com/showthread...hreadid=386218



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default Problem with cell value

With a formula in a cell -
when the results of the formula change it does not activate the change
event

but it will activate the calculate event

in ThisWorkbook module
Private Sub Workbook_SheetCalculate(ByVal Sh As Object)

End Sub

or
in the sheet module
Private Sub Worksheet_Calculate()

End Sub

or you can build some kind of compare or equals statement into your
change event
If Range("A1") = 0 then

elseif Range("A1") = 1 then

end if

--
steveB

Remove "AYN" from email to respond
"EMoe" wrote in message
...

Hello,
I got this code to work with the help of some of the experts from this
forum.
What is does is changes the color of a shape based on the value of a
cell. However, I've found that if I type 1 in the cell, the color
changes. If I type 0, the shape color changes like it should. The
problem is that when I put a formula in that cell that would return the
value of 1 or 0, nothing happens. I think this code is looking at the
formula, and not the value.

How do I alter this code so that I would respond to the cell value, and
not the formula. Or is there another code I could use.

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Me.Range("A1")) Is Nothing Then
With Me.Shapes(AutoShape1).Fill.ForeColor
Select Case Me.Range("A1").Value
Case 1: .SchemeColor = 2
Case 0: .SchemeColor = 12
Case Else: .SchemeColor = 11
End Select
End With
End If
End Sub

Thanks,
EMoe


--
EMoe
------------------------------------------------------------------------
EMoe's Profile:
http://www.excelforum.com/member.php...o&userid=23183
View this thread: http://www.excelforum.com/showthread...hreadid=386218



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Problem with cell value


I'll try this when I get back to work.

Thanks,
EMoe


--
EMoe
------------------------------------------------------------------------
EMoe's Profile: http://www.excelforum.com/member.php...o&userid=23183
View this thread: http://www.excelforum.com/showthread...hreadid=386218

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
Cell Underline problem underlines across width of cell tshoop7 Excel Worksheet Functions 1 July 24th 08 12:18 AM
Very Basic Problem - Merged Cell Equals Contents of a Single Cell jollynicechap Excel Worksheet Functions 3 December 29th 06 08:16 PM
Cell problem Patrick Excel Worksheet Functions 3 March 29th 05 03:33 PM
problem with cell reference in =sum(offset(cell reference,x,y,z,a)). Want cell ref to be variable. [email protected] Excel Worksheet Functions 2 December 11th 04 12:05 AM
Last cell problem Jac Tremblay[_3_] Excel Programming 0 November 1st 04 10:23 PM


All times are GMT +1. The time now is 10:21 AM.

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

About Us

"It's about Microsoft Excel"