Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
this is in a worksheet_open sub. the combobox is the only activex
control on the worksheet. what am i doing wrong? i tried "value" but that didn't work. but neither is listindex. i originally had it all in one line but when that didn't work i thought it might need a "with" statement (ThisWorkbook.Sheets("Income").OLEObjects ("cmbCounty").ListIndex = 0 'Value = "") thanks a lot for any advice. With ThisWorkbook.Sheets("Income") .OLEObjects("cmbCounty").ListIndex = 0 'Value = "" End With :) susan |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try setting the ListIndex to -1 (minus one) instead of 0.
-- Rick (MVP - Excel) "Susan" wrote in message ... this is in a worksheet_open sub. the combobox is the only activex control on the worksheet. what am i doing wrong? i tried "value" but that didn't work. but neither is listindex. i originally had it all in one line but when that didn't work i thought it might need a "with" statement (ThisWorkbook.Sheets("Income").OLEObjects ("cmbCounty").ListIndex = 0 'Value = "") thanks a lot for any advice. With ThisWorkbook.Sheets("Income") .OLEObjects("cmbCounty").ListIndex = 0 'Value = "" End With :) susan |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hmmmm. didn't work.
tried msgboxes before & after to see the value and neither mgbox got triggered, for some odd reason. the code before & below this section was accessed & performed. can't set a breakpoint & step through it because when i save & close the workbook, the breakpoint gets cleared. :( MsgBox ThisWorkbook.Sheets("Income").OLEObjects("cmbCount y").Text With ThisWorkbook.Sheets("Income") .OLEObjects("cmbCounty").ListIndex = -1 End With MsgBox ThisWorkbook.Sheets("Income").OLEObjects("cmbCount y").Text any other ideas? i'm thinking i'm going to have to copy this section of code to another module & play with it outside of the workbook_open sub to get it working, then move it back into the workbook_open sub. a thought - can oleobjects be accessed from a general module??? or perhaps can they only be accessed from sheet code? susan On Nov 16, 11:41*am, "Rick Rothstein" wrote: Try setting the ListIndex to -1 (minus one) instead of 0. -- Rick (MVP - Excel) "Susan" wrote in message ... this is in a worksheet_open sub. *the combobox is the only activex control on the worksheet. *what am i doing wrong? *i tried "value" but that didn't work. *but neither is listindex. *i originally had it all in one line but when that didn't work i thought it might need a "with" statement (ThisWorkbook.Sheets("Income").OLEObjects ("cmbCounty").ListIndex = 0 * 'Value = "") thanks a lot for any advice. * *With ThisWorkbook.Sheets("Income") * * *.OLEObjects("cmbCounty").ListIndex = 0 * 'Value = "" * *End With :) susan- Hide quoted text - - Show quoted text - |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
i got it
ThisWorkbook.Sheets("Income").cmbCounty.ListIndex = -1 don't know why it doesn't want the "oleobjects" in there, because i definitely used the activex control, but it works this way. thanks for all your help! susan On Nov 16, 12:24*pm, Susan wrote: hmmmm. *didn't work. tried msgboxes before & after to see the value and neither mgbox got triggered, for some odd reason. the code before & below this section was accessed & performed. can't set a breakpoint & step through it because when i save & close the workbook, the breakpoint gets cleared. *:( MsgBox ThisWorkbook.Sheets("Income").OLEObjects("cmbCount y").Text * * With ThisWorkbook.Sheets("Income") * * * .OLEObjects("cmbCounty").ListIndex = -1 * * End With MsgBox ThisWorkbook.Sheets("Income").OLEObjects("cmbCount y").Text any other ideas? *i'm thinking i'm going to have to copy this section of code to another module & play with it outside of the workbook_open sub to get it working, then move it back into the workbook_open sub. a thought - can oleobjects be accessed from a general module??? *or perhaps can they only be accessed from sheet code? susan On Nov 16, 11:41*am, "Rick Rothstein" wrote: Try setting the ListIndex to -1 (minus one) instead of 0. -- Rick (MVP - Excel) "Susan" wrote in message .... this is in a worksheet_open sub. *the combobox is the only activex control on the worksheet. *what am i doing wrong? *i tried "value" but that didn't work. *but neither is listindex. *i originally had it all in one line but when that didn't work i thought it might need a "with" statement (ThisWorkbook.Sheets("Income").OLEObjects ("cmbCounty").ListIndex = 0 * 'Value = "") thanks a lot for any advice. * *With ThisWorkbook.Sheets("Income") * * *.OLEObjects("cmbCounty").ListIndex = 0 * 'Value = "" * *End With :) susan- Hide quoted text - - Show quoted text -- Hide quoted text - - Show quoted text - |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You can do it that way but it's not always a good idea to hardcode objects
as you are. You almost had it right before, just missing '.Object' With ThisWorkbook.Sheets("Income") .OLEObjects("cmbCounty").Object.ListIndex = -1 End With Regards, Peter T "Susan" wrote in message ... i got it ThisWorkbook.Sheets("Income").cmbCounty.ListIndex = -1 don't know why it doesn't want the "oleobjects" in there, because i definitely used the activex control, but it works this way. thanks for all your help! susan On Nov 16, 12:24 pm, Susan wrote: hmmmm. didn't work. tried msgboxes before & after to see the value and neither mgbox got triggered, for some odd reason. the code before & below this section was accessed & performed. can't set a breakpoint & step through it because when i save & close the workbook, the breakpoint gets cleared. :( MsgBox ThisWorkbook.Sheets("Income").OLEObjects("cmbCount y").Text With ThisWorkbook.Sheets("Income") .OLEObjects("cmbCounty").ListIndex = -1 End With MsgBox ThisWorkbook.Sheets("Income").OLEObjects("cmbCount y").Text any other ideas? i'm thinking i'm going to have to copy this section of code to another module & play with it outside of the workbook_open sub to get it working, then move it back into the workbook_open sub. a thought - can oleobjects be accessed from a general module??? or perhaps can they only be accessed from sheet code? susan On Nov 16, 11:41 am, "Rick Rothstein" wrote: Try setting the ListIndex to -1 (minus one) instead of 0. -- Rick (MVP - Excel) "Susan" wrote in message ... this is in a worksheet_open sub. the combobox is the only activex control on the worksheet. what am i doing wrong? i tried "value" but that didn't work. but neither is listindex. i originally had it all in one line but when that didn't work i thought it might need a "with" statement (ThisWorkbook.Sheets("Income").OLEObjects ("cmbCounty").ListIndex = 0 'Value = "") thanks a lot for any advice. With ThisWorkbook.Sheets("Income") .OLEObjects("cmbCounty").ListIndex = 0 'Value = "" End With :) susan- Hide quoted text - - Show quoted text -- Hide quoted text - - Show quoted text - |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
ok, i'll fix it. thanks peter.
susan On Nov 16, 2:51*pm, "Peter T" <peter_t@discussions wrote: You can do it that way but it's not always a good idea to hardcode objects as you are. You almost had it right before, just missing '.Object' With ThisWorkbook.Sheets("Income") * .OLEObjects("cmbCounty").Object.ListIndex = -1 End With Regards, Peter T "Susan" wrote in message ... i got it ThisWorkbook.Sheets("Income").cmbCounty.ListIndex = -1 don't know why it doesn't want the "oleobjects" in there, because i definitely used the activex control, but it works this way. thanks for all your help! susan On Nov 16, 12:24 pm, Susan wrote: hmmmm. didn't work. tried msgboxes before & after to see the value and neither mgbox got triggered, for some odd reason. the code before & below this section was accessed & performed. can't set a breakpoint & step through it because when i save & close the workbook, the breakpoint gets cleared. :( MsgBox ThisWorkbook.Sheets("Income").OLEObjects("cmbCount y").Text With ThisWorkbook.Sheets("Income") .OLEObjects("cmbCounty").ListIndex = -1 End With MsgBox ThisWorkbook.Sheets("Income").OLEObjects("cmbCount y").Text any other ideas? i'm thinking i'm going to have to copy this section of code to another module & play with it outside of the workbook_open sub to get it working, then move it back into the workbook_open sub. a thought - can oleobjects be accessed from a general module??? or perhaps can they only be accessed from sheet code? susan On Nov 16, 11:41 am, "Rick Rothstein" wrote: Try setting the ListIndex to -1 (minus one) instead of 0. -- Rick (MVP - Excel) "Susan" wrote in message .... this is in a worksheet_open sub. the combobox is the only activex control on the worksheet. what am i doing wrong? i tried "value" but that didn't work. but neither is listindex. i originally had it all in one line but when that didn't work i thought it might need a "with" statement (ThisWorkbook.Sheets("Income").OLEObjects ("cmbCounty").ListIndex = 0 'Value = "") thanks a lot for any advice. With ThisWorkbook.Sheets("Income") .OLEObjects("cmbCounty").ListIndex = 0 'Value = "" End With :) susan- Hide quoted text - - Show quoted text -- Hide quoted text - - Show quoted text -- Hide quoted text - - Show quoted text - |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Susan
The default listindex for for ComboBox, DirListBox, and DriveListBox controls is -1 which indicates that no item is currently selected . If this post helps click Yes --------------- Jacob Skaria "Susan" wrote: this is in a worksheet_open sub. the combobox is the only activex control on the worksheet. what am i doing wrong? i tried "value" but that didn't work. but neither is listindex. i originally had it all in one line but when that didn't work i thought it might need a "with" statement (ThisWorkbook.Sheets("Income").OLEObjects ("cmbCounty").ListIndex = 0 'Value = "") thanks a lot for any advice. With ThisWorkbook.Sheets("Income") .OLEObjects("cmbCounty").ListIndex = 0 'Value = "" End With :) susan . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
combobox value blank | Excel Programming | |||
Reset values in a combobox | Excel Programming | |||
Combobox drops down blank row | Excel Programming | |||
reset a combobox | New Users to Excel | |||
Remove blank rows from combobox | Excel Programming |