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 Macro Skipping a column?

Good Morning all!

Question is why is this Macro (Originally done by Tom, attempted
modification by me :)) skipping a column before pasting its results..?

It opens a book, selects cells from Analysis sheet, and pastes it into
the existing open book first worksheet. Does the same thing for a second
sheet, but pasting it into exisitng open bok, second worksheet. Then
closes source. Then repeats.

For some reason it pastes into every second column, ie pastes into
column A, then column C, then column E. It does this on both 1st and 2nd
sheets its pasting into.... I need it to paste into every column, not
every second column

Any ideas...?

Regards

Darin



Sub consolidator3()
'CONSOLIDATES ANALYSIS and STATS SHEET
Dim i As Long, sName As String, sh As Worksheet
Dim dest As Range, bk As Workbook, bk1 As Workbook
Dim sh1 As Worksheet
Set bk1 = ThisWorkbook
i = 1
sName = Dir("D:\Documents and
Settings\dk\Desktop\Consolidation_AR_test_files\*. xls")
Do While sName < ""
Set bk = Workbooks.Open("D:\Documents and
Settings\dk\Desktop\Consolidation_AR_test_files\" & sName)

Set sh = bk.Worksheets("Analysis")
Set dest = ThisWorkbook.Worksheets(1).Cells(1, i)
i = i + 1
sh.Columns(3).Copy
dest.PasteSpecial xlValues
dest.PasteSpecial xlFormats
' write name of the workbook in row 1
dest.Value = sName

'now get stats and paste into Second Worksheet in book (RM stats)
Set sh = bk.Worksheets("stats")
Set dest = ThisWorkbook.Worksheets(2).Cells(1, i)
i = i + 1
sh.Columns(4).Copy
dest.PasteSpecial xlValues
dest.PasteSpecial xlFormats


bk.Close SaveChanges:=False
sName = Dir()
Loop
ThisWorkbook.Worksheets(1).Name = "Consol_AR"
ThisWorkbook.Worksheets(2).Name = "Sum_Stats" '


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
reference row on another sheet skipping zeros but not skipping li. Brennan Downes Excel Discussion (Misc queries) 2 April 2nd 23 01:28 PM
Skipping every other column for an Average. Empy Excel Worksheet Functions 2 June 17th 08 10:34 PM
Need help in numbering a column while skipping lines Gary Reger Excel Worksheet Functions 3 December 21st 05 10:00 PM
SKIPPING A COLUMN eternal_cat via OfficeKB.com Excel Programming 12 October 17th 05 04:13 AM
SKIPPING A COLUMN eternal_cat via OfficeKB.com Excel Worksheet Functions 1 October 14th 05 06:26 AM


All times are GMT +1. The time now is 01:43 AM.

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"