LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Len Len is offline
external usenet poster
 
Posts: 162
Default Adding New Sheets

Hi,

After few attempts, the following codes fails to add new sheets and
rename its sheet to this workbook after copying worksheet from each
excel file under MPV folder

Dim i%, SheetArg$()
Dim sPath As String
Dim sFile As Variant
Dim oSht As Integer
Dim ShtFile As String

Windows("ABC.xls").Activate
sPath = "D:\My Documents\MPV\"
sFile = Dir(sPath & "*.xls", vbNormal)
Workbooks.Open Filename:=sPath & sFile
Do While sFile < ""
oSht = Worksheets.Count
Workbooks(sFile).Sheets(1).Copy
Befo=Workbooks("ABC.xls").Sheets(oSht)
ShtFile = Left(sFile, InStrRev(sFile, ".") - 3)
ActiveSheet.Name = ShtFile
oSht = oSht + 1
Workbooks(sFile).Close SaveChanges:=False
sFile = Dir()
Loop

Any help will be appreciated and thanks in advance


Regards
Len
 
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
adding sheets ganga Excel Discussion (Misc queries) 2 June 16th 09 03:40 AM
Adding numbers from other sheets? Unforgiving Excel Programming 2 July 14th 08 08:54 AM
Adding Sheets [email protected] Excel Discussion (Misc queries) 2 May 23rd 06 03:04 PM
Macro for adding more sheets Dom Excel Discussion (Misc queries) 1 April 30th 06 06:16 AM
adding sheets together Andrea[_7_] Excel Programming 3 November 7th 03 06:40 PM


All times are GMT +1. The time now is 09:01 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"