Copy multiple columns to new sheet ignoring blank rows?

JumboCactuar

Well-known Member
Joined
Nov 16, 2016
Messages
785
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
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
sorry - also need a 4th column filled with a cell from each sheet
Cell H1 has the sheet name of each
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,215,771
Messages
6,126,799
Members
449,337
Latest member
BBV123

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
Back
Top