Populate userform textboxes and comboboxes

YellowSkin

New Member
Joined
Jun 9, 2020
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hi all,

Hope you can help me with below issue. Thank you in advance.


Context
I have a userform that requests the name of an entity. Once the name is entered the user can choose to collect data (if any). To do so I have created a button. Once clicked the idea is that other elements in the userform (i.e. other comboboxes and textboxes will be populated. However I cant seem to get the code to work.

VBA Code:
Sub loadData()

'Define variables
    entity = userform_assetEntry.combobox_entity.Value
    parentEntity_1 = userform_assetEntry.combobox_parent_entity_1.Value
    parentEntity_2 = userform_assetEntry.combobox_parent_entity_2.Value
    parentEntityPercentage_1 = userform_assetEntry.textbox_parent_1_percentage.Value
    parentEntityPercentage_2 = userform_assetEntry.textbox_parent_2_percentage.Value
    currencyCode = userform_assetEntry.textbox_currency.Value
    startFY = userform_assetEntry.textbox_startfy.Value
    jurisdiction = userform_assetEntry.textbox_jurisdiction.Value
    citRate = userform_assetEntry.textbox_cit_rate.Value
    specialRegime = userform_assetEntry.combobox_special_regime.Value

'push subject_entity to sheet5 - [I]this is done so that the relevant numbers are collected via a simple INDEX MATCH function. This part of the code works.[/I]

    Sheet5.Cells(2, 1).Value = entity

'load general information -[I] this is the part that DOESNT work. [/I]

    parentEntityPercentage_1 = Sheet5.Cells(2, 3).Value
    parentEntity_2 = Sheet5.Cells(2, 4).Value
    parentEntityPercentage_2 = Sheet5.Cells(2, 5).Value
    startFY = Sheet5.Cells(2, 9).Value
    jurisdiction = Sheet5.Cells(2, 10).Value
    currencyCode = Sheet5.Cells(2, 11).Value
    parentEntity_1 = Sheet5.Cells(2, 2).Value
    citRate = Sheet5.Cells(2, 12).Value
    specialRegime = Sheet5.Cells(2, 13).Value

'Load Asset Information
    'check of er informatie ingeladen moet worden
        
    'inladen van de informatie

    'naar volgende regel

End Sub
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Hi & welcome to MrExcel.
Is that code in the userform_assetEntry code module?
 
Upvote 0
To elaborate on the above. I have a sub that calls 'loadData' when clicked.
 
Upvote 0
Ok in that case try
VBA Code:
userform_assetEntry.textbox_parent_1_percentage.Value = Sheet5.Cells(2, 3).Value
 
Upvote 0
Amazing! This seems to work. Any idea why it didn't work when it was predefined as in my code?
 
Upvote 0
You were putting the cell values into variables, but not sending those values back to the controls.
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,427
Members
448,961
Latest member
nzskater

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