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 Modifying code to Consolidate only 1 column..

Hi there,

The code below correctly opens however many excel workbooks located
within a sub directory, and copies and pastes the first 4 columns into
another sheet. (end result is you have consolidated the 4 columns into
new sheet)

QUESTION I
I want to modify the code ONLY to copy column 2 into the new sheet, (and
do repetively for all books within the same sub directory) How do I do
so...? (My VB skills are slightly limited.., so not sure which variable
to change....)

Question II
Is there any way to turn off the auto alert when you open a book that
says "Do you want to enable Macros", and the auto alert when you close
the book that says "there is a large amount of data on the clipboard, do
you want it available for later use...?

Thanks!!!!
Regards

Darin

Sub Consolidator

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\user\Desktop\Projects\Projects_06\Consoli dation_test\results\*.
xls")
Do While sName < ""
Set bk = Workbooks.Open("D:\Documents and
Settings\user\Desktop\Projects\Projects_06\Consoli dation_test\results\"
& sName)
Set sh = bk.Worksheets("Answers")
Set dest = ThisWorkbook.Worksheets(1).Cells(1, i)
i = i + 1
sh.Columns(1).Resize(, 2).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.Select
ActiveSheet.Name = "Consolidated"



End Sub

*** 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
modifying code in run time alfaista Excel Programming 2 November 18th 04 10:09 PM
modifying formulas with code Rick B[_6_] Excel Programming 3 January 28th 04 02:03 PM
Need Help Modifying Code JStone0218 Excel Programming 2 January 19th 04 10:27 AM
Help modifying code BruceJ[_2_] Excel Programming 1 December 10th 03 12:52 AM
Modifying Code that deletes a Row Todd Huttenstine[_2_] Excel Programming 2 November 27th 03 10:41 PM


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