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: 1
Default Worksheet Overwrite Macro Change


Hi All,

I am using this macro to automatically copy worksheets from other files
to this file.

This has the code for automatically naming the new worksheets with the
count number when a worksheet of the same name already exists in the
file.

I want to take off this feature. I want the macro to overwrite the
sheets without uniquely naming the new sheets

I tried taking off the two lines of code. . but it gives me errors.

Can somebody help me. .

Here is the code.


Option Explicit

Sub CombineFiles()
Dim Path As String
Dim FileName As String
Dim Wkb As Workbook
Dim WS As Worksheet

Application.EnableEvents = False
Application.ScreenUpdating = False
Path = "C:\Documents and Settings\Desktop"
FileName = Dir(Path & "\*.xls", vbNormal)
Do Until FileName = ""
Set Wkb = Workbooks.Open(FileName:=Path & "\" & FileName)
For Each WS In Wkb.Worksheets
WS.Copy
After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Cou nt)
Next WS
Wkb.Close False
FileName = Dir()
Loop
Application.EnableEvents = True
Application.ScreenUpdating = True

End Sub


--
biojunkie
------------------------------------------------------------------------
biojunkie's Profile: http://www.excelforum.com/member.php...o&userid=17859
View this thread: http://www.excelforum.com/showthread...hreadid=391906

 
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
Worksheet Change Macro Help Vick Excel Discussion (Misc queries) 1 June 19th 09 10:25 PM
Worksheet change macro for paste special Phil Excel Discussion (Misc queries) 4 November 14th 08 05:42 PM
Worksheet change Macro Question Vick Excel Discussion (Misc queries) 11 January 30th 08 03:09 PM
Worksheet change Macro part 2 Vick Excel Discussion (Misc queries) 0 January 29th 08 07:36 PM
Overwrite Master sheet when using merge macro Mark Jackson Excel Programming 3 June 8th 05 09:33 AM


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