Load from a spreadsheet into a userform

gmazza76

Well-known Member
Joined
Mar 19, 2011
Messages
771
Office Version
  1. 365
Platform
  1. Windows
Afternoon,

I need to load about 6 sets of numbers onto a userform when the stats userform is loaded to give an overview to managers.

I am using the code below but it debugs out.
I have tried stepping into the code but it isnt showing anything.

Please help
Many Thanks
Gavin

Code:
'enters the date on the form
Private Sub userform_Initialize()
Dim Today
Today = Format(Now, "dd/m/yyyy")
Me.Today.Value = Today
Me.Today.Locked = True
 
Workbooks.Open Filename:="C:\Users\MAZZA\Documents\Gavin\Car Park\FYVData.xls" 'Home

On Error Resume Next
Set myBook = Application.Workbooks("FYVData.xls")
On Error GoTo 0
    
Dim iRow As Long
Dim ws As Worksheet
Dim lRow As Integer
Set ws = Worksheets("Breakdown Stats")
            FYVOverview.Show False
            FYVOverview.TextBox1.Value = Cells(C3)
            FYVOverview.TextBox7.Value = Cells(C4)
            FYVOverview.TextBox6.Value = Cells(C5)
 
 
End Sub
 
Many Thanks

It does pull the info in but gives the following

Run-time '400':

Form already displayed; cant show modally.

When i click debug it brings me back to the Sub Group7_Click() that loads the userform
 
Upvote 0

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
No idea offhand, unless you double-clicked the button that macro is attached to? Or assigned it to a button and included parentheses in the OnAction?
 
Upvote 0
Sorry,

I am sounding really thick.
The userform loads from a button.

What does
"parentheses in the OnAction?"
mean

Cheers
 
Upvote 0
What macro did you assign to the button exactly?
 
Upvote 0
I used a button to load the form as below
The code you gave i have added in the "Private Sub userform_Initialize()"

Is this correct ?

Code:
Sub Group7_Click()
    FYVOverview.Show
End Sub
 
Upvote 0
Is the first code you posted in the FYVOverview form? If so you are trying to reshow the form while it's loading, which is your problem. I have no idea why you are doing that so can't really say much more.
 
Upvote 0

Forum statistics

Threads
1,224,621
Messages
6,179,938
Members
452,949
Latest member
beartooth91

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