I have a userform that is populated from a worksheet containing saved chemical application records including date applied, site_Id, quantity applied, etc. The form contains a combobox ("cboChemicals") which is populated by a second worksheet "Chemicals". The Chemicals worksheet contains all the chemicals we use and the EPA registration number. When I retrieve a application record and populate the form it will contain, among other things, the name of the chemical used in the application. I want to set me.cboChemicals to the row in its list that equals the chemical used. Here is the code segment:
dim wb as workbook
dim ws_Chemicals as worksheet, rng as range
dim RowNum as integer
set wb = thisworkbook
set ws_Chemicals = wb.worksheets("Chemicals")
set rng = ws_Chemicals.Range("A1:A500").find(what:=Chem_Name,lookat:=xlwhole)
if not rng is nothing then
RowNum=rng.Row
me.cboChemicals=ws_Chemicals.cells(RowNum,1)
endif
********************************
Even though the combobox may display the name of the chemical, I know it isn't set to the row because cboChemicals.column(1) should return the EPA number and it doesn't. I've tried ListIndex and some of the other properties without success. I could populate the combobox with just the selected chemical and its EPA Number, but I would prefer to set the index to the row of the selected chemical. (I'm not sure I'm using the right terminology so I hope you can decifer what I'm trying to say.) Any suggestions would be greatly appreciated!
dim wb as workbook
dim ws_Chemicals as worksheet, rng as range
dim RowNum as integer
set wb = thisworkbook
set ws_Chemicals = wb.worksheets("Chemicals")
set rng = ws_Chemicals.Range("A1:A500").find(what:=Chem_Name,lookat:=xlwhole)
if not rng is nothing then
RowNum=rng.Row
me.cboChemicals=ws_Chemicals.cells(RowNum,1)
endif
********************************
Even though the combobox may display the name of the chemical, I know it isn't set to the row because cboChemicals.column(1) should return the EPA number and it doesn't. I've tried ListIndex and some of the other properties without success. I could populate the combobox with just the selected chemical and its EPA Number, but I would prefer to set the index to the row of the selected chemical. (I'm not sure I'm using the right terminology so I hope you can decifer what I'm trying to say.) Any suggestions would be greatly appreciated!