Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Combine data from two sheets in two one

Dear experts,
My scenario isn't that complex but obviously I am missing something:

I have two worksheet containing similar information (same amount of columns
and same amount of column names but different amount of rows).
From the first worksheet I select specific rows using an advanced filter. I
copy those to a newly created sheet.
From the second I apply the same advanced filter and would like to copy the
rows to the formerly newly created sheet without deleting the previous pasted
rows.
Be aware that I do not care if the rows are copied before or after the
previous pasted rows. But think about that the first paste will also paste
the column headers which should be excluded in the second paste.

I appreciate your help!

Holger

Here my code so far which results in an error that the range is not
appropriate selected:

Sub Combine_Sheets()

Dim LastRow As Range, LastRowNumber As Long

Application.ScreenUpdating = False

' Get Range for Advanced Filter from Basic Data Sheet
Sheets("Basic Data").Select
MyRange_CC = "J9:J" & (Worksheets("Basic Data").Range("I4").Cells + 8)
'Get Source_Sheet1
Sheets(Source_Sheet1).Select
Set LastRow = Cells(Rows.Count, "A").End(xlUp)
LastRowNumber = LastRow.Row

MyRange_Dataset = "A1:AF" & LastRowNumber
' apply advanced filter for MyRange on Source_Sheet1
Columns(MyColumns).Select
Range(MyRange_Dataset).AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
Sheets("Basic Data").Range(MyRange_CC), Unique:=False
' Copy & Paste Selection
With Selection
.CurrentRegion.Select
.SpecialCells(xlCellTypeVisible).Select
.Copy
End With
' Create Target_Sheet and paste
Sheets.Add Type:="Worksheet"
ActiveSheet.Name = "Target_Sheet"
Sheets("Target_Sheet").Select
ActiveSheet.Paste
Application.CutCopyMode = False

' apply advanced filter with same criteria on Source_Sheet2
Sheets("Source_Sheet2").Select
Columns(MyColumns).Select
Range(MyRange_Dataset).AdvancedFilter Action:=xlFilterInPlace,
CriteriaRange:= _
Sheets("Basic Data").Range(MyRange_CC), Unique:=False
' Copy & Paste Selection
With Selection
.CurrentRegion
.SpecialCells(xlCellTypeVisible).Select
.Copy
End With
Sheets("Target_Sheet").Select
' This is my try to paste it by shifting the existing cells downward
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=True, Transpose:=True

Application.CutCopyMode = False
End Sub
Reply
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
Combine 2 sheets into 1 that will update w/new data Ms. Von Excel Worksheet Functions 2 June 23rd 08 04:12 PM
Combine multiple sheets of data into one worksheet Jason Excel Discussion (Misc queries) 1 June 17th 07 01:07 PM
combine data from multiple sheets Roxypup Excel Discussion (Misc queries) 2 April 7th 06 07:40 AM
How do I combine and match data from 2 sheets CathyW Excel Discussion (Misc queries) 3 March 23rd 06 10:18 PM
How to append/combine (not add) data in several sheets into one? ParkCrescent Excel Discussion (Misc queries) 2 August 15th 05 01:28 PM


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