ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copying Selective columns (https://www.excelbanter.com/excel-programming/343164-copying-selective-columns.html)

Oldjay[_2_]

Copying Selective columns
 
I want a Macro that will select the A and the D columns (this column has
blank cells) of a database(database records is variable) and only copy
these two columns to a new sheet




Tom Ogilvy

Copying Selective columns
 
Sub aa()
Dim rng As Range
Set rng = Range(Cells(1, 1), Cells(Rows.Count, 1).End(xlUp))
Set rng = Union(rng, rng.Offset(0, 3))
Worksheets.Add
Range("A1").Select
rng.Copy
ActiveSheet.Paste

End Sub

or if you want them in columns A and D on the new sheet

Dim rng as Range
set rng = Range(cells(1,2),cells(rows.count,1).End(xlup))
Worksheets.Add
rng.copy Destination:=Range("A1")
rng.offset(0,3).Copy Destination:=Range("D1")

--
Regards,
Tom Ogilvy





"Oldjay" wrote in message
...
I want a Macro that will select the A and the D columns (this column has
blank cells) of a database(database records is variable) and only copy
these two columns to a new sheet







All times are GMT +1. The time now is 10:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com