Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Selecting an existing worksheet

Good afternoon,

Based on the following Microsoft article, I am retrieving data from SQL
Server.

http://msdn.microsoft.com/en-us/library/bb964684.aspx

What this article does is create a a new Excel worksheet and populate that
sheet with the data (roughly on page 13 of document).

employeeWS = DirectCast(Me.Application.Sheets.Add(), Excel.Worksheet)
employeeWS.Name = "Employees"

I want to use an EXISTING worksheet, but I cannot get this to work. I have
tried several options, such as using:

Me.Application.Sheets("employee").Select

But it either bombs there or on subsequent code (depending on other options
I try).

I don't want to create a NEW worksheet so how do I use the existing
worksheet (the one that has the focus).

Thanks in advance. It is greatly appreciated.


--
Thanks,

Scott
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Selecting an existing worksheet

Hi,

Maybe this

Set employeeWS = ActiveSheet
employeeWS.Name = "Employees"

Mike

"SQLScott" wrote:

Good afternoon,

Based on the following Microsoft article, I am retrieving data from SQL
Server.

http://msdn.microsoft.com/en-us/library/bb964684.aspx

What this article does is create a a new Excel worksheet and populate that
sheet with the data (roughly on page 13 of document).

employeeWS = DirectCast(Me.Application.Sheets.Add(), Excel.Worksheet)
employeeWS.Name = "Employees"

I want to use an EXISTING worksheet, but I cannot get this to work. I have
tried several options, such as using:

Me.Application.Sheets("employee").Select

But it either bombs there or on subsequent code (depending on other options
I try).

I don't want to create a NEW worksheet so how do I use the existing
worksheet (the one that has the focus).

Thanks in advance. It is greatly appreciated.


--
Thanks,

Scott

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Selecting an existing worksheet

No, but you gave pointed me down the right path. It is this:

employeeWS = DirectCast(Me.Application.ActiveSheet, Excel.Worksheet)
employeeWS.Name = "Employees"

Thanks for your help Mike! Greatly appreciated.
--
Thanks,

Scott


"Mike H" wrote:

Hi,

Maybe this

Set employeeWS = ActiveSheet
employeeWS.Name = "Employees"

Mike

"SQLScott" wrote:

Good afternoon,

Based on the following Microsoft article, I am retrieving data from SQL
Server.

http://msdn.microsoft.com/en-us/library/bb964684.aspx

What this article does is create a a new Excel worksheet and populate that
sheet with the data (roughly on page 13 of document).

employeeWS = DirectCast(Me.Application.Sheets.Add(), Excel.Worksheet)
employeeWS.Name = "Employees"

I want to use an EXISTING worksheet, but I cannot get this to work. I have
tried several options, such as using:

Me.Application.Sheets("employee").Select

But it either bombs there or on subsequent code (depending on other options
I try).

I don't want to create a NEW worksheet so how do I use the existing
worksheet (the one that has the focus).

Thanks in advance. It is greatly appreciated.


--
Thanks,

Scott

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
Creating a PivotTable w/o selecting data in an existing PivotTable Damian Excel Discussion (Misc queries) 6 November 2nd 07 04:44 PM
Create Worksheet From Values in Existing Cells Using Existing Worksheet as Template. Ardy Excel Programming 18 November 29th 06 03:23 AM
How do I conditionally build worksheet from existing worksheet? Bob G Excel Discussion (Misc queries) 1 July 3rd 05 06:40 PM
selecting cell range in other worksheet without switching to worksheet suzetter[_4_] Excel Programming 4 June 22nd 05 08:55 PM
Find existing worksheet Rob[_16_] Excel Programming 3 March 1st 04 04:58 AM


All times are GMT +1. The time now is 05:28 AM.

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

About Us

"It's about Microsoft Excel"