Userform error when other workbook open

rhombus4

Well-known Member
Joined
May 26, 2010
Messages
586
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have a userform which I open in workbook1, sometimes while the userform is open I need to access a different workbook.

Problem Is when I try and enter data in workbook 2 I get Run-time Error '424' Object required"

I do have worksheet calculate event in the userform, is this what is causing the error or could something else be an issue

i.e.

Private Sub ws_Calculate()
Me.Textbox1 = ws.Range("myrange").Text
End Sub

Do I need to add thisworkbook or userform1 or something similar in the code.

I already have it as modeless when the userform is opened
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Where are you defining/setting ws?
 
Upvote 0
In the Userform Code at the top I have

Private WithEvents ws As Excel.Worksheet

Then in Private Sub UserForm_Initialize()

I have

Set ws = ThisWorkbook.Sheets("Data")
 
Upvote 0

Forum statistics

Threads
1,215,452
Messages
6,124,916
Members
449,195
Latest member
Stevenciu

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