Copy multiple columns to new sheet ignoring blank rows?

JumboCactuar

Well-known Member
Joined
Nov 16, 2016
Messages
726
Office Version
  1. 365
Platform
  1. Windows
Hi,
i need to copy all rows of data of Columns A,O,P where column A isn't blank (starting at row 10) to a new sheet
and repeat this on sheets1-5

sheet2 data merged underneath sheet1 data etc..

i have asked similar before but cant find the thread - instead of looping i think its possible with union join ?

Output should be 3 columns on sheet6 without any spaces

This is to prepare data for an SQL insert where I need to remove blank rows

any help appreciated
 

Some videos you may like

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

JumboCactuar

Well-known Member
Joined
Nov 16, 2016
Messages
726
Office Version
  1. 365
Platform
  1. Windows
sorry - also need a 4th column filled with a cell from each sheet
Cell H1 has the sheet name of each
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,343
Office Version
  1. 365
Platform
  1. Windows
How about
VBA Code:
Sub JumboCactur()
   Dim i As Long
   Dim Ws As Worksheet
   
   Set Ws = Sheets.Add(, Sheets(Sheets.count))
   For i = 1 To Sheets.count - 1
      With Sheets(i)
         With .Range("A10", .Range("A" & Rows.count).End(xlUp))
            Intersect(.SpecialCells(xlConstants).EntireRow, .Parent.Range("A:A,O:P")).Copy Ws.Range("A" & Rows.count).End(xlUp).Offset(1)
            Ws.Range(Ws.Range("D" & Rows.count).End(xlUp).Offset(1), Ws.Range("A" & Rows.count).End(xlUp).Offset(, 3)).Value = .Range("H1").Value
         End With
      End With
   Next i
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,127,159
Messages
5,623,092
Members
415,951
Latest member
Shen1986

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top