LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default VBA to merge worksheets (only populated rows)

I have some basic code that we use to pull together data from several
worksheets within a single workbook. It should only pull in rows that have
data in column A and ignore the two rows used for headings from each of the
other sheet to avoid them being repeated all the way down this new page when
they are coppied across.

For the most part it works, however we noticed it seems to randomly add some
extra rows to the bottom of the consolidated list. Originally these were
blank but we now find that they are actually some of the rows from the very
first worksheet to be pulled in where no data exists in column A. No idea
why these appear at the end of the table nor why they are appearing in the
first place.

Code is as follows, any help to ensure it only copies across rows where there
is something in column A would be much appreciated. Even better would be
some pointers on how to get it to look at other workbooks hosted on
SharePoint....

(I started tying to add comments to help explain the function but not
finished yet)

Sub Merge()
Dim ws As Worksheet
'clear the current worksheet (i.e. consolidated plan) of all data except
the two header rows
ActiveSheet.UsedRange.Offset(2).Clear
'For all tabs in the workbook
For Each ws In ActiveWorkbook.Worksheets
'Exclude the ITA Internal sheet
If ws.Name < "ITA-Internal" Then
'Exclude the consolidated plan sheet
If ws.Name < ActiveSheet.Name Then
'When reviewing data to be copied exclude the first two rows
ws.UsedRange.Offset(2).Copy
'for all rows where there is a value in column A ....
With Range("A65536").End(xlUp).Offset(1, 0)
.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
.PasteSpecial Paste:=xlFormats, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
End With
End If
End If
Next
End Sub

 
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
Need help linking spreadsheets and displaying only populated rows demarchi Excel Discussion (Misc queries) 1 November 26th 08 10:19 PM
Automatically gray out rows when a particular field is populated Bob Luck Excel Discussion (Misc queries) 4 August 30th 08 05:24 PM
How do I merge date from two populated columns into one column? Morgan788 Setting up and Configuration of Excel 0 June 11th 08 03:16 PM
Master Worksheet populated by other Worksheets? Steve Lundwall Excel Worksheet Functions 0 March 3rd 06 01:38 PM
how to count populated rows? Ryan Cain New Users to Excel 4 August 12th 05 04:35 AM


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