Populate ComboBox from record

adambc

Active Member
Joined
Jan 13, 2020
Messages
380
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
I want to read a record into a UserForm (to update the record) - I have this working fine in one Workbook as follows ...

VBA Code:
Private Sub UserForm_Initialize()

'Populate all ComboBoxes with dropdowm lists (from "Look Up Tables")
With Sheets("Look Up Tables")
    Me.cboStrategyAlignment.List = .Range("B2", .Cells(.Rows.Count, "B").End(xlUp)).value
    Me.cboDepartment.List = .Range("C2", .Cells(.Rows.Count, "C").End(xlUp)).value
    Me.cboStatus.List = .Range("F2", .Cells(.Rows.Count, "F").End(xlUp)).value
    Me.cboImpactExisting.List = .Range("G2", .Cells(.Rows.Count, "G").End(xlUp)).value
    Me.cboLikelihoodExisting.List = .Range("I2", .Cells(.Rows.Count, "I").End(xlUp)).value
    Me.cboImpactAdditional.List = .Range("G2", .Cells(.Rows.Count, "G").End(xlUp)).value
    Me.cboLikelihoodAdditional.List = .Range("I2", .Cells(.Rows.Count, "I").End(xlUp)).value
End With

SearchIDRow = Application.Match(SearchIDValue, Sheets("All Risks").Columns("A"), 0)

txtRiskID = Cells(SearchIDRow, 1)
txtDateAdded = Cells(SearchIDRow, 2)
cboSpokeFocus = Cells(SearchIDRow, 3)
cboStrategyAlignment = Cells(SearchIDRow, 4)
cboDepartment = Cells(SearchIDRow, 5)

Etc, etc ...

But in a new Workbook the following fails on the last line (Run-time error '380': Could not set the Value property. Invalid property value.) ...

Code:
Private Sub UserForm_Initialize()

'Populate all ComboBoxes with dropdown lists
With Sheets("Look Up Tables")
    Me.cboDepartment.List = .Range("A2", .Cells(.Rows.Count, "A").End(xlUp)).value
    Me.cboIncidentType.List = .Range("B2", .Cells(.Rows.Count, "B").End(xlUp)).value
    Me.cboIncidentNature.List = .Range("C2", .Cells(.Rows.Count, "C").End(xlUp)).value
    Me.cboIncidentFormat.List = .Range("D2", .Cells(.Rows.Count, "D").End(xlUp)).value
    Me.cboDataType.List = .Range("E2", .Cells(.Rows.Count, "E").End(xlUp)).value
    Me.cboInternalExternal.List = .Range("F2", .Cells(.Rows.Count, "F").End(xlUp)).value
    Me.cboDataSubjectsAdvised.List = .Range("G2", .Cells(.Rows.Count, "G").End(xlUp)).value
    Me.cboCausedBy.List = .Range("H2", .Cells(.Rows.Count, "H").End(xlUp)).value
    Me.cboImpact.List = .Range("I2", .Cells(.Rows.Count, "I").End(xlUp)).value
    Me.cboLikelihood.List = .Range("K2", .Cells(.Rows.Count, "K").End(xlUp)).value
    Me.cboStatus.List = .Range("M2", .Cells(.Rows.Count, "M").End(xlUp)).value
End With

SearchIDRow = Application.Match(SearchIDValue, Sheets("Incident Log").Columns("A"), 0)

txtIncidentID = Cells(SearchIDRow, 1)

MsgBox Cells(SearchIDRow, 2)

cboStatus = Cells(SearchIDRow, 2)

Etc, etc ...

... even though the MsgBox returns the correct value!

Any ideas?

Many thanks ...
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

Forum statistics

Threads
1,215,703
Messages
6,126,320
Members
449,308
Latest member
Ronaldj

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top