PDA

View Full Version : Copy col help



KK1966
04-06-2013, 12:06 AM
Hi, experts

How do i do copy column from sheet1 (B:C) to sheet2 find the which empty column then paste there ?

for example
if sheet2 column A to E have data then sheet1 B:C paste to sheet2 F & G

do macros can do it ?

patel
04-06-2013, 02:40 AM
Sub a()
Lastcol = Sheets(2).UsedRange.Columns.Count
Sheets(1).Columns("B:C").Copy Sheets(2).Columns(Lastcol + 1)
End Sub

mdmackillop
04-06-2013, 07:39 AM
Sub b()
Dim LastCol As Long
With Sheets(2)
LastCol = .Cells.Find("*", after:=.Cells(1, 1), searchdirection:=xlPrevious, searchorder:=xlByColumns).Column + 1
Sheets(1).Columns("B:C").Copy .Cells(1, LastCol)
End With
End Sub

@Patel

If you only have data in columns F&G in a sheet, UsedRange column count will be 2 if no other cells have previously been populated

patel
04-06-2013, 12:02 PM
Thank you mdmackillop (http://www.vbaexpress.com/forum/member.php?u=87) you are right