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


I have pieced together this code from several sources:

Private Sub ComboBox1_change()

Dim WatchRange As Range
Dim CellVal As Integer
If Target.Cells.Count 1 Then Exit Sub
If Target = "" Or Not IsNumeric(Target) Then Exit Sub
CellVal = Target
Set WatchRange = Range("B2:B2")
Set rng = Range("F7:G7")

If Not Intersect(Target, WatchRange) Is Nothing Then
Select Case CellVal
Case 1
rng.Interior.ColorIndex = 3
Case 2
rng.Interior.ColorIndex = 46
Case 3
rng.Interior.ColorIndex = 6
Case 4
rng.Interior.ColorIndex = 10
Case 5
rng.Interior.ColorIndex = 5
Case 6
rng.Interior.ColorIndex = 13
End Select
End If
End Sub

If I use Worksheet_change instead of ComboBox change, the spreadshee
updates color as expected when I manually change the value of cell B2.
However, I am trying to get the above code to work when I use a form
combobox to change the value of cell B2.

If you want to look at the actual spreadsheet I have uploaded it to:
http://home.swbell.net/nate-sus/excel/colors.xls

Thanks

--
Lotus12
-----------------------------------------------------------------------
Lotus123's Profile: http://www.excelforum.com/member.php...fo&userid=2861
View this thread: http://www.excelforum.com/showthread.php?threadid=56805

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Combobox Question

Try replacing Target with Selection.

--
Jim
"Lotus123" wrote in
message ...
|
| I have pieced together this code from several sources:
|
| Private Sub ComboBox1_change()
|
| Dim WatchRange As Range
| Dim CellVal As Integer
| If Target.Cells.Count 1 Then Exit Sub
| If Target = "" Or Not IsNumeric(Target) Then Exit Sub
| CellVal = Target
| Set WatchRange = Range("B2:B2")
| Set rng = Range("F7:G7")
|
| If Not Intersect(Target, WatchRange) Is Nothing Then
| Select Case CellVal
| Case 1
| rng.Interior.ColorIndex = 3
| Case 2
| rng.Interior.ColorIndex = 46
| Case 3
| rng.Interior.ColorIndex = 6
| Case 4
| rng.Interior.ColorIndex = 10
| Case 5
| rng.Interior.ColorIndex = 5
| Case 6
| rng.Interior.ColorIndex = 13
| End Select
| End If
| End Sub
|
| If I use Worksheet_change instead of ComboBox change, the spreadsheet
| updates color as expected when I manually change the value of cell B2.
| However, I am trying to get the above code to work when I use a forms
| combobox to change the value of cell B2.
|
| If you want to look at the actual spreadsheet I have uploaded it to:
| http://home.swbell.net/nate-sus/excel/colors.xls
|
| Thanks!
|
|
| --
| Lotus123
| ------------------------------------------------------------------------
| Lotus123's Profile:
http://www.excelforum.com/member.php...o&userid=28611
| View this thread: http://www.excelforum.com/showthread...hreadid=568052
|


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
Combobox question mrdata[_32_] Excel Programming 0 July 18th 06 10:37 PM
combobox question Gary Keramidas Excel Programming 2 January 28th 06 04:04 PM
combobox Question Greg B Excel Discussion (Misc queries) 2 September 2nd 05 04:22 PM
ComboBox Question Kevin Excel Programming 1 December 7th 03 04:54 PM
ComboBox Question Terry Detrie Excel Programming 2 October 18th 03 02:55 PM


All times are GMT +1. The time now is 01:54 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"