Solved

macro to fill down range in different workbooks

Posted on 2014-02-05
4
361 Views
Last Modified: 2014-02-05
I have 2 workbooks "A" and "B" including 2 sheets with the same name "data".

If the last row in WbA "data" is 250 and the last row in "WbB data" is 200, then the macro should fill down the range "A200-H250" in WbB

Thanks,
CC
0
Comment
Question by:CC10
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 51

Expert Comment

by:Rgonzo1971
ID: 39835891
Hi,

pls try


Sub Macro()

LastRowA = Sheets("A").Range("A" & Cells.Rows.Count).End(xlUp).Row
LastRowB = Sheets("B").Range("A" & Cells.Rows.Count).End(xlUp).Row
If LastRowB < LastRowA Then
    Sheets("B").Range("A" & LastRowB & ":H" & LastRowA).FillDown
'ElseIf LastRowB > LastRowA Then   ' if reprocicate
'    Sheets("A").Range("A" & LastRowA & ":H" & LastRowB).FillDown
End If


End Sub

Open in new window

Regards
0
 

Author Comment

by:CC10
ID: 39836248
Hello,  that works fine but I didn't realise that I need to copy the range rather then just fill down.
So if lastrowB is 200 and lastrow A is 250, the macro should copy the range Sheets ("A").Range A200:H250 to Sheets("B") Range A 200:H250

I could just link the ranges with formulas but that takes up space and I would prefer just to copy and paste.

Sorry about that.
0
 
LVL 51

Accepted Solution

by:
Rgonzo1971 earned 400 total points
ID: 39836466
Hi,

pls try
Sub Macro1()

LastRowA = Sheets("A").Range("A" & Cells.Rows.Count).End(xlUp).Row
LastRowB = Sheets("B").Range("A" & Cells.Rows.Count).End(xlUp).Row
If LastRowB < LastRowA Then
    Sheets("A").Range("A" & LastRowB & ":H" & LastRowA).Copy _
        Destination:=Sheets("B").Range("A" & LastRowB)
End If

End Sub

Open in new window

Regards
0
 

Author Closing Comment

by:CC10
ID: 39836510
Perfect. Thanks very much
0

Featured Post

SuperAntiSpyware Licenses Discounted by 25% !

Exclusive offer to Experts Exchange Members!
Buy SuperAntiSpyware License(s) from us and save 25% on the regular purchase price.
- Includes Full SuperAntiSpyware Vendor Support Entitlements
- Your Subscription does not begin until you activate your license
- Buy for your friends

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager is not included in Office 2013. This comes as a shock to users upgrading from earlier versions of Office, such as 2007 and 2010, where Picture Manager was included as a standard application. This article explains how…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question