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: 397
Default Why is Sheet deleted when Macro runs...

Guys

Howdie guys

VBA below works perfectly to consolidate data from the specified
location. HOWEVER to run the macro I inserted a sheet called MACROS
which has the instructions for users and what to click when. Problem is
when I run the macro it deletes the Macros sheet. I tried very hiding
the Macros sheet, but that doesnt seem to work. Any ideas...?

Appreicate the help

Thanks

D

Sub Consolidator()
Worksheets("Macros").Visible = xlVeryHidden

Sheets("Sheet1").Select

Dim i As Long, sName As String, sh As Worksheet
Dim dest As Range, bk As Workbook
i = 1
sName = Dir("D:\Documents and Settings\me\Desktop\results\*.xls")
Do While sName < ""
Set bk = Workbooks.Open("D:\Documents and
Settings\darinkramer\Desktop\Projects\Projects_06\ Consolidation_test\res
ults\" & sName)
Set sh = bk.Worksheets("Answers")
Set dest = ThisWorkbook.Worksheets(1).Cells(1, i)
i = i + 4
sh.Columns(1).Resize(, 4).Copy
dest.PasteSpecial xlValues
dest.PasteSpecial xlFormats
' write name of the workbook in row 1
dest.Value = sName
' close the workbook
bk.Close SaveChanges:=False
sName = Dir()
Loop

ActiveSheet.Name = "Consolidated"


*** Sent via Developersdex http://www.developersdex.com ***
 
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
VBA macro runs fine, but freezes if I try to do ANYTHING else whileit runs Rruffpaw Setting up and Configuration of Excel 1 September 17th 11 01:25 PM
Why macro runs on the same sheet? Harshad[_2_] Excel Discussion (Misc queries) 1 September 15th 08 09:39 AM
One macro runs then it auto runs another macro PG Excel Discussion (Misc queries) 2 September 1st 06 09:30 PM
Disable Macro automatically when a sheet is deleted bayhe Excel Programming 1 January 18th 05 09:13 AM
Disable Macro automatically when a sheet is deleted bayhe Excel Programming 1 January 18th 05 07:51 AM


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