Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default select instruction is not able to work with a sheet

Hi

I'm using second time this site, I'm not sure how it's working, from first
post I still don't get any comment.

This issue is when a excel file is opened, we have an instruction like
sheet("Setup").select inside workbook_open event, and in some excels this
works fine, when it does'nt work a message "error 57121 defined by the
object" comes.

Reading a Microsoft information, I changed the instruction creating first an
object for the especific sheet and then using the same select instruction, it
works fine but still I don't know this is the right way.

Thanks in advance for your comments

--
Regards
Jorge Mendoza V
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 140
Default select instruction is not able to work with a sheet

Hi

Not sure what it is that you are trying to do, and having to assume that
when you open the workbook you want a certain sheet to be the active sheet?

within the Workbook_Open event
you could use any of the following

Sheets("Setup").Activate
ActiveWorkbook.Worksheets("Setup").Activate

Try not to use select, and to be honest in most cases there isnt a need to
use activate either, if you have set reference to an object you are able to
work with it without Selecting/Activating

HTH


"JorgeLMV" wrote:

Hi

I'm using second time this site, I'm not sure how it's working, from first
post I still don't get any comment.

This issue is when a excel file is opened, we have an instruction like
sheet("Setup").select inside workbook_open event, and in some excels this
works fine, when it does'nt work a message "error 57121 defined by the
object" comes.

Reading a Microsoft information, I changed the instruction creating first an
object for the especific sheet and then using the same select instruction, it
works fine but still I don't know this is the right way.

Thanks in advance for your comments

--
Regards
Jorge Mendoza V

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default select instruction is not able to work with a sheet

Try something like this

Sub Test()
Dim myWS As Worksheet
Dim mySheet As String
Set myWS = ActiveSheet

mySheet = "Sheet4" '<~~~change as needed
Set myWS = Nothing

On Error Resume Next
Set myWS = Sheets(mySheet)
On Error GoTo 0

If Not myWS Is Nothing Then
myWS.Select
Else
MsgBox ("Worksheet " & mySheet & " does not exist in this workbook")
Sheets(1).Select 'Selects the first sheet in the workbook
End If

End Sub

HTH,
Barb Reinhardt
"JorgeLMV" wrote:

Hi

I'm using second time this site, I'm not sure how it's working, from first
post I still don't get any comment.

This issue is when a excel file is opened, we have an instruction like
sheet("Setup").select inside workbook_open event, and in some excels this
works fine, when it does'nt work a message "error 57121 defined by the
object" comes.

Reading a Microsoft information, I changed the instruction creating first an
object for the especific sheet and then using the same select instruction, it
works fine but still I don't know this is the right way.

Thanks in advance for your comments

--
Regards
Jorge Mendoza V

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
select only last 30 days of a work sheet Tyler Excel Worksheet Functions 2 January 7th 09 01:39 AM
extracting totals from 1 work sheet to another work work sheet cj Excel Discussion (Misc queries) 2 October 27th 07 10:54 PM
Populating work sheet combox with another work sheet values sjayar Excel Discussion (Misc queries) 1 October 29th 05 03:22 PM
LeftFooterPicture instruction does not appear to work Guackyxxx Excel Programming 4 November 16th 04 11:35 PM
Find instruction fails (from foreign sheet) Kinne Excel Programming 2 August 11th 03 01:48 PM


All times are GMT +1. The time now is 11:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"