ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   difficulty opening userform (https://www.excelbanter.com/excel-programming/375766-difficulty-opening-userform.html)

CMcK

difficulty opening userform
 
Hi,

My userform sources data from cells in a worksheet ("Projects"). However,
when the other worksheet in my workbook ("Timesheet") is the active
worksheet, the userform will not launch. Instead I get a run-time error:
'Select method of Range class failed'

Can someone please explain why this occurs.

Many thanks.

CMcK

Tom Ogilvy

difficulty opening userform
 
If you have code in the sheet module for Projects and it is of the form

Range("A1").Select

if Projects is not the activesheet, this code will raise an error because it
is implicitly qualified as

worksheets("Projects").Range("A1").select

and since projects is not the activesheet, you get the error.

Change your code to

ActiveSheet.Range("A1").Select

possibly - it depends on what you are doing.

--
Regards,
Tom Ogilvy




"CMcK" wrote:

Hi,

My userform sources data from cells in a worksheet ("Projects"). However,
when the other worksheet in my workbook ("Timesheet") is the active
worksheet, the userform will not launch. Instead I get a run-time error:
'Select method of Range class failed'

Can someone please explain why this occurs.

Many thanks.

CMcK


CMcK

difficulty opening userform
 
Hi Tom,

I tried implementing the change you recommended and then running the
userform from the 'Timesheet' worksheet and the following error came up:

Run-time error 1004:
Application-defined or object-defined error

Any ideas?...

CMcK



"Tom Ogilvy" wrote:

If you have code in the sheet module for Projects and it is of the form

Range("A1").Select

if Projects is not the activesheet, this code will raise an error because it
is implicitly qualified as

worksheets("Projects").Range("A1").select

and since projects is not the activesheet, you get the error.

Change your code to

ActiveSheet.Range("A1").Select

possibly - it depends on what you are doing.

--
Regards,
Tom Ogilvy




"CMcK" wrote:

Hi,

My userform sources data from cells in a worksheet ("Projects"). However,
when the other worksheet in my workbook ("Timesheet") is the active
worksheet, the userform will not launch. Instead I get a run-time error:
'Select method of Range class failed'

Can someone please explain why this occurs.

Many thanks.

CMcK


Tom Ogilvy

difficulty opening userform
 
Any ideas?...

That you have something screwed up in your code. Beyond that, I would have
to be clairvoyant. If you used

Activesheet.Range("A1").Select

then I don't see how that would raise such an error unless Timesheet is a
chart sheet or you have something unusual selected. (make sure timesheet
is actually a worksheet and not a macro sheet or something).

--
Regards,
Tom Ogilvy

"CMcK" wrote in message
...
Hi Tom,

I tried implementing the change you recommended and then running the
userform from the 'Timesheet' worksheet and the following error came up:

Run-time error 1004:
Application-defined or object-defined error

Any ideas?...

CMcK



"Tom Ogilvy" wrote:

If you have code in the sheet module for Projects and it is of the form

Range("A1").Select

if Projects is not the activesheet, this code will raise an error because
it
is implicitly qualified as

worksheets("Projects").Range("A1").select

and since projects is not the activesheet, you get the error.

Change your code to

ActiveSheet.Range("A1").Select

possibly - it depends on what you are doing.

--
Regards,
Tom Ogilvy




"CMcK" wrote:

Hi,

My userform sources data from cells in a worksheet ("Projects").
However,
when the other worksheet in my workbook ("Timesheet") is the active
worksheet, the userform will not launch. Instead I get a run-time
error:
'Select method of Range class failed'

Can someone please explain why this occurs.

Many thanks.

CMcK





All times are GMT +1. The time now is 09:07 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com