Intermittent Row Source Issue

dellehurley

Board Regular
Joined
Sep 26, 2009
Messages
171
Office Version
  1. 365
Platform
  1. Windows
Hi
I have a procedure to reset a userform. It works fine except for every now and then the "Could not set the rowsource property. Invalid property value". I cannot find what the issue is, I have tried changing the rowsource (eg named source, by naming the range) while the issue is debugging the second rowsource throws the error too if I comment out this line. BUT the weird thing is if I end the procedure and then reenter the exact/different details into the userform and the error does not appear again for hours. Any ideas what the issue might be?
Dannielle
The line of code with the issue plus named range also the range also saved in name manager.
VBA Code:
PopWs.Range("A2:A" & aLastRow).Name = "Categories"

    .cmbCategory.RowSource = "Populate!Categories"   'Populate!A2:A" & aLastRow


The entire procedure
VBA Code:
Sub Reset_Enter()

Dim DbLastRow As Long
Dim BgtLastRow As Long
Dim Payee As String
Dim aLastRow As Long
Dim cLastRow As Long
Dim TomorrowDt As Date

DbLastRow = DbWs.Cells(DbWs.Rows.Count, "A").End(xlUp).Row
BgtLastRow = BgtWs.Cells(BgtWs.Rows.Count, "A").End(xlUp).Row
cLastRow = PopWs.Cells(PopWs.Rows.Count, "C").End(xlUp).Row
aLastRow = PopWs.Cells(PopWs.Rows.Count, "A").End(xlUp).Row
TodayDt = Format(Now(), "dd/mm/yyyy")
TomorrowDt = Format(Now + 1, "dd/mm/yyyy")

DbWs.Range("A1:G" & DbLastRow).Name = "AllDatabase"
DbWs.Range("A2:G" & DbLastRow).Name = "Database"
PopWs.Range("C2:E" & cLastRow).Name = "Payees"
PopWs.Range("A2:A" & aLastRow).Name = "Categories"
BgtWs.Range("A2:N" & BgtLastRow).Name = "BudgetList"

BgtWs.Range("ALL_ONE").Value = ""
SchWs.Cells(1, 1).Value = "" 'date held when start date given is in the past and next date not supplied until Submit Rpt cal

DbWs.Range("Database").Sort Key1:=DbWs.Range("A:A"), order1:=xlAscending, Header:=xlYes
PopWs.Range("Categories").Sort Key1:=PopWs.Range("Categories"), order1:=xlAscending, Header:=xlYes
PopWs.Range("Payees").Sort Key1:=PopWs.Range("C:C"), order1:=xlAscending, Header:=xlYes
    
With frmEnter
    .chkVary.Value = False
    .txtAmount.Value = ""
    .cmdEdit.Caption = ""
    .txtRowNumber = ""
    .txtEndDt = ""
    .chkCat.Value = False
    .chkPay.Value = False
    .chkNoEnd.Value = False
    .cmbFreq.Value = ""
    .cmbFreq.AddItem "Once Only"
    .cmbFreq.AddItem "Daily"
    .cmbFreq.AddItem "Weekly"
    .cmbFreq.AddItem "Fortnightly"
    .cmbFreq.AddItem "Monthly"
    .cmbFreq.AddItem "Quarterly"
    .cmbFreq.AddItem "Tri Annually"
    .cmbFreq.AddItem "Bi Annually"
    .cmbFreq.AddItem "Annually"
    .cmbCategory.Value = ""
    .cmbCategory.BackColor = RGB(255, 255, 255)
    .cmbCategory.RowSource = "Populate!Categories"   'Populate!A2:A" & aLastRow
    .cmbPayee.Value = ""
    .cmbPayee.BackColor = RGB(255, 255, 255)
    .cmbPayee.RowSource = "Populate!Payees"
    .optBill.Value = False
    .optDeposit.Value = False
    Call EnterColour
    With .DTPickersStart
        .Value = Now
        .CustomFormat = "dd/mm/yyyy"
    End With
    With .DTPickerEnd
            .CheckBox = True
            .Value = Null
            .CustomFormat = "dd/mm/yyyy"
            .MinDate = TomorrowDt
            .UpDown = True
    End With
    
    .txtRepeat.Value = ""
    .lstDatabase.ColumnCount = 14
    .lstDatabase.ColumnHeads = True
    .lstDatabase.ColumnWidths = "50,50,50,25,50,50,100,80,75,10,50,0,0,0"
    
    If BgtLastRow > 1 Then
        .lstDatabase.RowSource = "BudgetList"
    Else
        .lstDatabase.RowSource = "Budget!A2:N2"
    End If
 End With
   
End Sub
Budgeting Tool 1.xlsm
A
1Categories
2 + Add Item
3Electricity
4Gifts
5Groceries
6Holiday
7Housing
8Insurance
9Medical & Healthcare
10Mortgage
11Pension
12Personal
13Rates
14Recreation
15Salary
16Savings
17Transportation
18Utilities
19Water
Populate
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Well, do not use Rowsource:
This is from VBA for smarties How to fill a Combobox / Listbox
It says:
"If you use 'rowsource' you make a direct link to a certain range in a worksheet.
Combined with the combobox it can cause Excel to blackout, because any change in the combobox will be transferred directly to the 'source'.
Excel has proven not to be able to do this correctly.
Besides: the changing of the source at every change in the combobox slows down your code.
You should reduce the reading/writing from/to a workbook in your code as much as possible."


Without Rowsource, you can insert the range directly into the listbox like this:
First, clear Rowsource property of the combobox, then:
Combobox1.List = Sheets("Sheet1").Range("A1:A10").Value
or using a named range:
Combobox1.List =Range("myRange").Value
 
Upvote 0
Solution
Well, do not use Rowsource:
This is from VBA for smarties How to fill a Combobox / Listbox
It says:
"If you use 'rowsource' you make a direct link to a certain range in a worksheet.
Combined with the combobox it can cause Excel to blackout, because any change in the combobox will be transferred directly to the 'source'.
Excel has proven not to be able to do this correctly.
Besides: the changing of the source at every change in the combobox slows down your code.
You should reduce the reading/writing from/to a workbook in your code as much as possible."


Without Rowsource, you can insert the range directly into the listbox like this:
First, clear Rowsource property of the combobox, then:
Combobox1.List = Sheets("Sheet1").Range("A1:A10").Value
or using a named range:
Combobox1.List =Range("myRange").Value
Thank you for that, I will update the file now and I truly appreciate the help.
Dannielle
 
Upvote 0
You're welcome, glad to help & thanks for the feedback.:)
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,678
Members
449,116
Latest member
HypnoFant

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