#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 150
Default find sheet

I have a small marco that loads data from a file from another application
into a workbook in Excel 2003. Sometimes the number of rows exceeds the
65,000+ cap so the remaining data spills over to a second sheet, sometimes
not.

I need a line or two that looks for sheet2: if it finds id it copies all the
data from sheets 1 & 2. If there is no sheet 2, the procedure continues and
it loads sheet 1.

Nothing I try seems to work. I am a beginner with VBA.
--
stan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default find sheet

Stan,

Have a look he
http://www.cpearson.com/excel/ImportBigFiles.aspx

DB

"stan" wrote in message
...
I have a small marco that loads data from a file from another application
into a workbook in Excel 2003. Sometimes the number of rows exceeds the
65,000+ cap so the remaining data spills over to a second sheet, sometimes
not.

I need a line or two that looks for sheet2: if it finds id it copies all

the
data from sheets 1 & 2. If there is no sheet 2, the procedure continues

and
it loads sheet 1.

Nothing I try seems to work. I am a beginner with VBA.
--
stan



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default find sheet

Dim myWS as excel.worksheet

on error resume next
Set myWS = ActiveBook.Worksheets("Sheet2")
on error goto 0

if myws is nothing then
MSgbox("There is no Sheet2")
end if


'Alternatively, you can try this if there are only two worksheets in the
workbook.

if ActiveBook.WOrksheets.count = 2 then
Msgbox("There are two worksheets")
elseif activebook.worksheets.count = 1 then
Msgbox("There is one worksheet")

end if

HTH,

Barb Reinhardt



"stan" wrote:

I have a small marco that loads data from a file from another application
into a workbook in Excel 2003. Sometimes the number of rows exceeds the
65,000+ cap so the remaining data spills over to a second sheet, sometimes
not.

I need a line or two that looks for sheet2: if it finds id it copies all the
data from sheets 1 & 2. If there is no sheet 2, the procedure continues and
it loads sheet 1.

Nothing I try seems to work. I am a beginner with VBA.
--
stan

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 150
Default find sheet

Works prefectly. Thank you.
--
stan


"Barb Reinhardt" wrote:

Dim myWS as excel.worksheet

on error resume next
Set myWS = ActiveBook.Worksheets("Sheet2")
on error goto 0

if myws is nothing then
MSgbox("There is no Sheet2")
end if


'Alternatively, you can try this if there are only two worksheets in the
workbook.

if ActiveBook.WOrksheets.count = 2 then
Msgbox("There are two worksheets")
elseif activebook.worksheets.count = 1 then
Msgbox("There is one worksheet")

end if

HTH,

Barb Reinhardt



"stan" wrote:

I have a small marco that loads data from a file from another application
into a workbook in Excel 2003. Sometimes the number of rows exceeds the
65,000+ cap so the remaining data spills over to a second sheet, sometimes
not.

I need a line or two that looks for sheet2: if it finds id it copies all the
data from sheets 1 & 2. If there is no sheet 2, the procedure continues and
it loads sheet 1.

Nothing I try seems to work. I am a beginner with VBA.
--
stan

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
Find value from one sheet and replace value in second sheet JohnM Excel Programming 3 August 25th 09 04:01 PM
macro to find data from one sheet & copy in another sheet Eddy Stan Excel Programming 6 November 29th 08 11:40 AM
Find value in sheet 1 and copy matching row from sheet 2 Also Excel Programming 1 January 8th 08 11:49 AM
Find value from sheet 1 on sheet 2 and copy to an offset from there L. Howard Kittle Excel Programming 3 March 2nd 07 09:32 PM
how to find and copy values on sheet 2, based on a list on sheet 1 evanmacnz Excel Programming 4 February 7th 05 08:33 PM


All times are GMT +1. The time now is 05:31 PM.

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"