Using the PasteSpecial & xlPasteValues funct
Solved/Closed1 response
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
Jul 3, 2010 at 02:12 AM
Jul 3, 2010 at 02:12 AM
Try this
Sub Combine() Dim J As Integer On Error Resume Next Sheets(1).Select Worksheets.Add ' add a sheet in first place Sheets(1).Name = "Combined" ' copy headings Sheets(2).Activate Range("A1").EntireRow.Select Selection.Copy Destination:=Sheets(1).Range("A1") ' work through sheets For J = 2 To Sheets.Count ' from sheet 2 to last sheet Sheets(J).Activate ' make the sheet active Range("A1").Select Selection.CurrentRegion.Select ' select all active cells in this sheets ' select all lines except title Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1).Select 'copy the selection Selection.Copy ' select the sheets(1). NOTE SHEET(1) needs to be visible Sheets(1).Select ' In column A, find the last non-blank cell and select one cell down from that cell Range("A" & Rows.Count).End(xlUp)(2).Select ' this is in case you want to retain the format too from the src. Remove the ' to activate the code 'Selection.PasteSpecial xlPasteAll 'paste the copied data as values Selection.PasteSpecial xlPasteValues Next End Sub
Jul 6, 2010 at 09:27 AM