ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   copy two columns without blanks in the first column (https://www.excelbanter.com/excel-programming/362382-copy-two-columns-without-blanks-first-column.html)

jeffm

copy two columns without blanks in the first column
 
Hopefully someone out there can make this happen for me. I have data
coming from SQL into Excel that includes dates (in column "a", for
ex.), and then two additional data elements (columns "b" and "c" for
ex.) of data. I need to sort through column "b", and where a value
exists, copy that cell and the cell in column "a" to a second worksheet
into the same columnar format. The trick that is stumping me is I need
to skip the blanks in column "b". In other words, sheet2 needs to have
column "a" and 'b" without the blanks. The column range is from
a6:a110, b6:b110, c6:c110.

If I can get that part, then I can get add the next column to do the
same to another sheet. I would sure appreciate the help.

Jeff


tom

copy two columns without blanks in the first column
 
Jeff, this code should do what you're looking for:
Sub Copy()
Range("B1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=2, Criteria1:="<"
Range("A1:B25").Select
Selection.Copy
Sheets("Sheet2").Select
Range("A1").Select
ActiveSheet.Paste
Range("A1").Select
Sheets("Sheet1").Select
Application.CutCopyMode = False
Range("A1").Select
Selection.AutoFilter
End Sub

HTH
Tom

"jeffm" wrote:

Hopefully someone out there can make this happen for me. I have data
coming from SQL into Excel that includes dates (in column "a", for
ex.), and then two additional data elements (columns "b" and "c" for
ex.) of data. I need to sort through column "b", and where a value
exists, copy that cell and the cell in column "a" to a second worksheet
into the same columnar format. The trick that is stumping me is I need
to skip the blanks in column "b". In other words, sheet2 needs to have
column "a" and 'b" without the blanks. The column range is from
a6:a110, b6:b110, c6:c110.

If I can get that part, then I can get add the next column to do the
same to another sheet. I would sure appreciate the help.

Jeff



jeffm

copy two columns without blanks in the first column
 
Tom,

Thanks. It works great! The old autofilter trick.......

Jeff



All times are GMT +1. The time now is 11:16 PM.

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