Solved

Set Excel Form RowSource Dynamically

Posted on 2011-02-18
3
349 Views
Last Modified: 2012-05-11
I have an Excel form and depending on which category the user selects, I want the rowsource properly to the combob box to change.  However, this code is run, I get a datatype mismatch.  I want to use range names rather than cell references as the ranges grow and contract according to data needed.
Private Sub optActiveMiscel_Click()
'Range name for this data is ss_ACTIVEMISC
'Data header is ACTIVE MISCELLANEOUS in column H
    Me.lblProfileName.Caption = "Profile Name"
    Me.lblURLSectorSummary.Caption = "Detail URL"
    Me.txtURLSectorSummary.Visible = True
    Me.lblURLSectorDetail.Visible = False
    Me.txtURLSectorDetail.Visible = False
    Me.lblURLRatingSummary.Visible = False
    Me.txtURLRatingSummary.Visible = False
    Me.lblURLRatingDetail.Visible = False
    Me.txtURLRatingDetail.Visible = False
    Me.cboPortCode.RowSource = ThisWorkbook.Worksheets("Settings").Range("cd_ActivePortfolios")
End Sub

Open in new window

0
Comment
Question by:ssmith94015
3 Comments
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 250 total points
ID: 34927329
RowSource is a String, but I'd suggest you use List:
Me.cboPortCode.List = ThisWorkbook.Worksheets("Settings").Range("cd_ActivePortfolios").Value

Open in new window

0
 
LVL 24

Assisted Solution

by:StephenJR
StephenJR earned 250 total points
ID: 34927330
Does this work?

Me.cboPortCode.RowSource = "cd_ActivePortfolios"
0
 

Author Closing Comment

by:ssmith94015
ID: 34927431
They both worked.  SstephenJR, what is curious is I tried that code version first and it returned an error.  I must have had a typo that I did not see.  Since this workbook is opened with several others, I am going to use the ThisWorkbook approach for the bond project, but I can use the shorter version in a separate project that only uses one workbook so am splitting points as they both did what I want but for different uses.  BTW, I am just starting this project and as I normally program in ACCESS, Excel forms are a little strange to me so will be posting more questions on this project as I go along - so be on the lookout!
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question