LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Handling 2 workbooks

Hi !

-Running Windows2k pro and Excel97

I work with two workbooks and want to export several worksheets from one
workbook to the other.

Here's my (BAD) code :

'================================================= ==================================
Sub TestExport()

Dim Source$, Destination$, SrcSheetName$()

ReDim SrcSheetsName$(1 To ActiveWorkbook.Worksheets.Count)
Source$ = ThisWorkbook.Name
Destination$ = "C:\Bulletins\3F\Bulletins3F.xls"

intPtr2 = 1
For intPtr1 = 1 To ActiveWorkbook.Worksheets.Count
strTemp1 = Right(Sheets(intPtr1).Name, 2)
If InStr(strTemp1, " P") Then
SrcSheetsName$(intPtr2) = Sheets(intPtr1).Name
intPtr2 = intPtr2 + 1
End If
Next intPtr1
intPtr2 = intPtr2 - 1

For intPtr1 = 1 To intPtr2
If SheetExists(Workbooks(Destination$).Sheets(SrcShee tsName$(intPtr1)))
Then
Workbooks(Destination$).Sheets(SrcSheetsName$(intP tr1)).Delete
End If
Workbooks(Source$).Sheets(SrcSheetsName$(intPtr1)) .Move
After:=Workbooks(Destination$).Sheets(1)
Next intPtr1

End Sub
'==============================
Public Function SheetExists(shtname As String) As Integer
Dim tptr%, tnbsheets%
SheetExists = 0
tnbsheets% = ActiveWorkbook.Worksheets.Count
For tptr% = 1 To tnbsheets%
If Worksheets(tptr%).Name = shtname Then
SheetExists = 1
Exit Function
End If
Next tptr%
End Function
'==============================



Question : how can I put that to work ??


Thanks by advance for your help and regards from Belgium,
Herve+
 
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
Error Handling Steph[_6_] Excel Programming 1 August 25th 05 03:44 PM
workbooks.open and error handling John Keith[_2_] Excel Programming 5 August 18th 05 05:16 PM
Error handling with a handling routine ben Excel Programming 0 March 15th 05 03:01 PM
Error handling V. Roe Excel Programming 2 February 27th 04 08:04 PM
Error Handling Todd Excel Programming 1 February 13th 04 11:29 PM


All times are GMT +1. The time now is 07:29 PM.

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"