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

I have a combobox which changes certain cells on a spreadsheet depending on
the CB selection and the content of several other cells. The problem I have
is that if one particular cell does not have a value entered, the data in
the code assumes a certain set of conditions. If data is then entered in the
cell, the other data is not corrected as it depends on CB LostFocus.

Is there a way to disable the CB but still leave it visible until certain
cells in the sheet are populated? I know about the Enabled property, but I'm
not sure how to detect the presence of data in particular cells except from
within a subroutine. I suspect I need to use the Worksheet SelectionChange,
but I only want the code to test conditions when particular cells are
changed.

Am I being thick, here?


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

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
if application.CountA(Range("A1,B9,C13,D21") < 4 then
me.combobox1.enabled = False
Else
me.Combobox1.enabled = True
End if
End Sub

--
Regards,
Tom Ogilvy

Ian Coates wrote in message
...
I have a combobox which changes certain cells on a spreadsheet depending

on
the CB selection and the content of several other cells. The problem I

have
is that if one particular cell does not have a value entered, the data in
the code assumes a certain set of conditions. If data is then entered in

the
cell, the other data is not corrected as it depends on CB LostFocus.

Is there a way to disable the CB but still leave it visible until certain
cells in the sheet are populated? I know about the Enabled property, but

I'm
not sure how to detect the presence of data in particular cells except

from
within a subroutine. I suspect I need to use the Worksheet

SelectionChange,
but I only want the code to test conditions when particular cells are
changed.

Am I being thick, here?




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Combobox problem

I'm having a problem with this, Tom.

I copied the code directly into my VBA editor and changed the cell (now O2)
and the criteria (now <1) but it doesn't work. I startd to have a look at
the help regarding the terms used. I cam unstuck with CountA which doesn't
appear in help. Also, what is the significance of me before combobox1?

Ian

"Tom Ogilvy" wrote in message
...
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
if application.CountA(Range("A1,B9,C13,D21") < 4 then
me.combobox1.enabled = False
Else
me.Combobox1.enabled = True
End if
End Sub

--
Regards,
Tom Ogilvy

Ian Coates wrote in message
...
I have a combobox which changes certain cells on a spreadsheet depending

on
the CB selection and the content of several other cells. The problem I

have
is that if one particular cell does not have a value entered, the data

in
the code assumes a certain set of conditions. If data is then entered in

the
cell, the other data is not corrected as it depends on CB LostFocus.

Is there a way to disable the CB but still leave it visible until

certain
cells in the sheet are populated? I know about the Enabled property, but

I'm
not sure how to detect the presence of data in particular cells except

from
within a subroutine. I suspect I need to use the Worksheet

SelectionChange,
but I only want the code to test conditions when particular cells are
changed.

Am I being thick, here?






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Combobox problem

You originally said there were multiple cells that needed to have values.

If you only want to test if O2 is empty

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
if Target.Count 1 then exit sub
if Target.Address = "$O$2" then
if isempty(me.Range(""O2")) then
me.combobox1.enabled = False
Else
me.Combobox1.enabled = True
End if
End If
End Sub

Me refers to the sheet holding the code.

--
Regards,
Tom Ogilvy



"Ian Coates" wrote in message
...
I'm having a problem with this, Tom.

I copied the code directly into my VBA editor and changed the cell (now

O2)
and the criteria (now <1) but it doesn't work. I startd to have a look at
the help regarding the terms used. I cam unstuck with CountA which doesn't
appear in help. Also, what is the significance of me before combobox1?

Ian

"Tom Ogilvy" wrote in message
...
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
if application.CountA(Range("A1,B9,C13,D21") < 4 then
me.combobox1.enabled = False
Else
me.Combobox1.enabled = True
End if
End Sub

--
Regards,
Tom Ogilvy

Ian Coates wrote in message
...
I have a combobox which changes certain cells on a spreadsheet

depending
on
the CB selection and the content of several other cells. The problem I

have
is that if one particular cell does not have a value entered, the data

in
the code assumes a certain set of conditions. If data is then entered

in
the
cell, the other data is not corrected as it depends on CB LostFocus.

Is there a way to disable the CB but still leave it visible until

certain
cells in the sheet are populated? I know about the Enabled property,

but
I'm
not sure how to detect the presence of data in particular cells except

from
within a subroutine. I suspect I need to use the Worksheet

SelectionChange,
but I only want the code to test conditions when particular cells are
changed.

Am I being thick, here?








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Combobox problem

Sorry Tom. I didn't realise I'd have to us edifferent code for single
and multiple cells. Your single cell solution worked perfectly and I
have a multiple cell requirement in another spreadsheet so I'll check
our your other solution when I get round to that.

Many thanks

Ian



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


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 problem hoyos Excel Discussion (Misc queries) 4 December 10th 09 11:16 AM
Problem Using Delete Key Because of Combobox Joseph Fletcher Excel Discussion (Misc queries) 11 February 23rd 07 01:45 PM
Complex Combobox problem . mattis2k[_2_] Excel Programming 1 November 14th 03 11:15 AM
Activation combobox problem. chris[_7_] Excel Programming 1 October 20th 03 06:32 PM
ComboBox Problem Tressa Excel Programming 2 August 27th 03 08:58 PM


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