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 programming not working

If anyone can help?!

Problem I have is that my combobox has values and if you
select the lowest value (12) first then any larger value
it works fine, but if you select a larger value fisrt then
a lower value second, nothing happens. Here is the code I
have.

Private Sub ComboBox1_Change()

If ComboBox1.Value = 12 Then Range
("A8:G49,K8:Q49").Interior.ColorIndex = 15 Else
If ComboBox1.Value = 18 Then Range
("A8:G10,K8:Q10").Interior.ColorIndex = 0 And _
Range("A11:G49,K11:Q49").Interior.ColorIndex = 15 Else
If ComboBox1.Value = 20 Then Range
("A8:G11,K8:Q11").Interior.ColorIndex = 0 And _
Range("A12:G49,K12:Q49").Interior.ColorIndex = 15 Else
If ComboBox1.Value = 24 Then Range
("A8:G13,K8:Q13").Interior.ColorIndex = 0 And _
Range("A14:G49,K14:Q49").Interior.ColorIndex = 15 Else
If ComboBox1.Value = 30 Then Range
("A8:G16,K8:Q16").Interior.ColorIndex = 0 And _
Range("A17:G49,K17:Q49").Interior.ColorIndex = 15 Else
If ComboBox1.Value = 42 Then Range
("A8:G22,K8:Q22").Interior.ColorIndex = 0 And _
Range("A23:G49,K23:Q49").Interior.ColorIndex = 15 Else
If ComboBox1.Value = 54 Then Range
("A8:G28,K8:Q28").Interior.ColorIndex = 0 And _
Range("A29:G49,K29:Q49").Interior.ColorIndex = 15 Else
If ComboBox1.Value = 72 Then Range
("A8:G37,K8:Q37").Interior.ColorIndex = 0 And _
Range("A38:G49,K38:Q49").Interior.ColorIndex = 15 Else
If ComboBox1.Value = 84 Then Range
("A8:G43,K8:Q43").Interior.ColorIndex = 0 And _
Range("A44:G49,K44:Q49").Interior.ColorIndex = 15 Else
If ComboBox1.Value = 96 Then Range
("A8:G49,K8:Q49").Interior.ColorIndex = 0

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default ComboBox programming not working

Try this:

Private Sub ComboBox1_Change()
Select Case CLng(Combobox1.Value)
Case 12
Range("A8:G49,K8:Q49").Interior.ColorIndex = 15
Case 18
Range("A8:G10,K8:Q10").Interior.ColorIndex = 0
Range("A11:G49,K11:Q49").Interior.ColorIndex = 15
Case 20
Range("A8:G11,K8:Q11").Interior.ColorIndex = 0
Range("A12:G49,K12:Q49").Interior.ColorIndex = 15
Case 24
Range("A8:G13,K8:Q13").Interior.ColorIndex = 0
Range("A14:G49,K14:Q49").Interior.ColorIndex = 15
Case 30
Range("A8:G16,K8:Q16").Interior.ColorIndex = 0
Range("A17:G49,K17:Q49").Interior.ColorIndex = 15
Case 42
Range("A8:G22,K8:Q22").Interior.ColorIndex = 0
Range("A23:G49,K23:Q49").Interior.ColorIndex = 15
Case 54
Range("A8:G28,K8:Q28").Interior.ColorIndex = 0
Range("A29:G49,K29:Q49").Interior.ColorIndex = 15
Case 72
Range("A8:G37,K8:Q37").Interior.ColorIndex = 0
Range("A38:G49,K38:Q49").Interior.ColorIndex = 15
Case 84
Range("A8:G43,K8:Q43").Interior.ColorIndex = 0
Range("A44:G49,K44:Q49").Interior.ColorIndex = 15
Case 96
Range("A8:G49,K8:Q49").Interior.ColorIndex = 0
End Select
End Sub


--
Regards,
Tom Ogilvy

"DontKnowWhatImDoing" wrote in message
...
If anyone can help?!

Problem I have is that my combobox has values and if you
select the lowest value (12) first then any larger value
it works fine, but if you select a larger value fisrt then
a lower value second, nothing happens. Here is the code I
have.

Private Sub ComboBox1_Change()

If ComboBox1.Value = 12 Then Range
("A8:G49,K8:Q49").Interior.ColorIndex = 15 Else
If ComboBox1.Value = 18 Then Range
("A8:G10,K8:Q10").Interior.ColorIndex = 0 And _
Range("A11:G49,K11:Q49").Interior.ColorIndex = 15 Else
If ComboBox1.Value = 20 Then Range
("A8:G11,K8:Q11").Interior.ColorIndex = 0 And _
Range("A12:G49,K12:Q49").Interior.ColorIndex = 15 Else
If ComboBox1.Value = 24 Then Range
("A8:G13,K8:Q13").Interior.ColorIndex = 0 And _
Range("A14:G49,K14:Q49").Interior.ColorIndex = 15 Else
If ComboBox1.Value = 30 Then Range
("A8:G16,K8:Q16").Interior.ColorIndex = 0 And _
Range("A17:G49,K17:Q49").Interior.ColorIndex = 15 Else
If ComboBox1.Value = 42 Then Range
("A8:G22,K8:Q22").Interior.ColorIndex = 0 And _
Range("A23:G49,K23:Q49").Interior.ColorIndex = 15 Else
If ComboBox1.Value = 54 Then Range
("A8:G28,K8:Q28").Interior.ColorIndex = 0 And _
Range("A29:G49,K29:Q49").Interior.ColorIndex = 15 Else
If ComboBox1.Value = 72 Then Range
("A8:G37,K8:Q37").Interior.ColorIndex = 0 And _
Range("A38:G49,K38:Q49").Interior.ColorIndex = 15 Else
If ComboBox1.Value = 84 Then Range
("A8:G43,K8:Q43").Interior.ColorIndex = 0 And _
Range("A44:G49,K44:Q49").Interior.ColorIndex = 15 Else
If ComboBox1.Value = 96 Then Range
("A8:G49,K8:Q49").Interior.ColorIndex = 0

End Sub




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default ComboBox programming not working

Try this instead

Private Sub ComboBox1_Change()

Select Case ComboBox1.Value
case12
Range("A8:G49,K8:Q49").Interior.ColorIndex = 15
Case 18
Range("A8:G10,K8:Q10").Interior.ColorIndex = 0
Range("A11:G49,K11:Q49").Interior.ColorIndex = 15
Case 20
Range("A8:G11,K8:Q11").Interior.ColorIndex = 0
Range("A12:G49,K12:Q49").Interior.ColorIndex = 15
Case 24
Range("A8:G13,K8:Q13").Interior.ColorIndex = 0
Range("A14:G49,K14:Q49").Interior.ColorIndex = 15
Case 30
Range("A8:G16,K8:Q16").Interior.ColorIndex = 0
Range("A17:G49,K17:Q49").Interior.ColorIndex = 15
Case 42
Range("A8:G22,K8:Q22").Interior.ColorIndex = 0
Range("A23:G49,K23:Q49").Interior.ColorIndex = 15
Case 54
Range("A8:G28,K8:Q28").Interior.ColorIndex = 0
Range("A29:G49,K29:Q49").Interior.ColorIndex = 15
Case 72
Range("A8:G37,K8:Q37").Interior.ColorIndex = 0
Range("A38:G49,K38:Q49").Interior.ColorIndex = 15
Case 84
Range("A8:G43,K8:Q43").Interior.ColorIndex = 0
Range("A44:G49,K44:Q49").Interior.ColorIndex = 15
Case 96
Range("A8:G49,K8:Q49").Interior.ColorIndex = 0
End Select
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"DontKnowWhatImDoing" wrote in message
...
If anyone can help?!

Problem I have is that my combobox has values and if you
select the lowest value (12) first then any larger value
it works fine, but if you select a larger value fisrt then
a lower value second, nothing happens. Here is the code I
have.

Private Sub ComboBox1_Change()

If ComboBox1.Value = 12 Then Range
("A8:G49,K8:Q49").Interior.ColorIndex = 15 Else
If ComboBox1.Value = 18 Then Range
("A8:G10,K8:Q10").Interior.ColorIndex = 0 And _
Range("A11:G49,K11:Q49").Interior.ColorIndex = 15 Else
If ComboBox1.Value = 20 Then Range
("A8:G11,K8:Q11").Interior.ColorIndex = 0 And _
Range("A12:G49,K12:Q49").Interior.ColorIndex = 15 Else
If ComboBox1.Value = 24 Then Range
("A8:G13,K8:Q13").Interior.ColorIndex = 0 And _
Range("A14:G49,K14:Q49").Interior.ColorIndex = 15 Else
If ComboBox1.Value = 30 Then Range
("A8:G16,K8:Q16").Interior.ColorIndex = 0 And _
Range("A17:G49,K17:Q49").Interior.ColorIndex = 15 Else
If ComboBox1.Value = 42 Then Range
("A8:G22,K8:Q22").Interior.ColorIndex = 0 And _
Range("A23:G49,K23:Q49").Interior.ColorIndex = 15 Else
If ComboBox1.Value = 54 Then Range
("A8:G28,K8:Q28").Interior.ColorIndex = 0 And _
Range("A29:G49,K29:Q49").Interior.ColorIndex = 15 Else
If ComboBox1.Value = 72 Then Range
("A8:G37,K8:Q37").Interior.ColorIndex = 0 And _
Range("A38:G49,K38:Q49").Interior.ColorIndex = 15 Else
If ComboBox1.Value = 84 Then Range
("A8:G43,K8:Q43").Interior.ColorIndex = 0 And _
Range("A44:G49,K44:Q49").Interior.ColorIndex = 15 Else
If ComboBox1.Value = 96 Then Range
("A8:G49,K8:Q49").Interior.ColorIndex = 0

End Sub




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
fill combobox depending on selection from another combobox Adam Francis Excel Discussion (Misc queries) 2 July 24th 08 07:39 PM
programming help biker man Excel Discussion (Misc queries) 2 July 22nd 07 11:54 PM
combobox not working tina Excel Worksheet Functions 1 November 10th 05 12:05 PM
Combobox programming Christian Reusch Excel Programming 2 January 6th 04 04:44 PM
Help With Simple Combobox Programming MAB[_3_] Excel Programming 1 August 27th 03 04:23 PM


All times are GMT +1. The time now is 06:15 PM.

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"