PC Review


Reply
Thread Tools Rate Thread

Copy Active Range from one workbook to another

 
 
jat
Guest
Posts: n/a
 
      16th Dec 2009
i need a few lines of code to determine the active rows in columns A and B
and copy from one work book to another.

i kind of understand the loop, but not a lot.

i need to select/copy the active cells in workbook one (always Columns A and
B) and paste them in the next blank row in Column A/B of workbook two.

i know that to find the next blank cell where to paste is the following:

Range("A1").Select
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = True

help would be appreciated,

jatman

 
Reply With Quote
 
 
 
 
marcus
Guest
Posts: n/a
 
      17th Dec 2009
Hi Jatman

This uses the Autofilter to copy the cells with data in Column A over
to another workbook and places them at the bottom of the used range in
this workbook. Change to suit.

Take care

Marcus

Option Explicit

Sub test()
Dim wb1 As Workbook
Dim wb2 As Workbook
Dim lw As Integer
Dim lr As Integer

Set wb1 = ActiveWorkbook
Set wb2 = Workbooks("BOOK3")'Change to your workbook name
lr = Range("A" & Rows.Count).End(xlUp).Row
lw = wb2.Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row

Columns(1).AutoFilter Field:=1, Criteria1:="<>"
Range(Cells(2, 1), Cells(lr, 2)).Copy wb2.Sheets("Sheet1").Range("A" &
lw)

End Sub
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy Range from Open Workbook to Active Workbook Forgone Microsoft Excel Programming 0 17th Jul 2009 01:46 AM
Copy Range to a New WorkBook + Name Sheet a cell Value + Name WorkBook another Celll Value Corey Microsoft Excel Programming 2 2nd Nov 2006 05:01 AM
copy worksheet from closed workbook to active workbook using vba =?Utf-8?B?bWFuZ28=?= Microsoft Excel Worksheet Functions 6 9th Dec 2004 07:55 AM
Copy a range of cells in an unopened workbook and paste it to the current workbook topstar Microsoft Excel Programming 3 24th Jun 2004 12:50 PM
Copy Modules from One workbook to Active Workbook Jim Gifford Microsoft Excel Programming 1 18th Nov 2003 12:30 PM


Features
 

Advertising
 

Newsgroups
 


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