Copy Paste and Extend Row Formulas

Papi

Well-known Member
Joined
May 22, 2007
Messages
1,592
I have a workbook that opens another workbook, does some sorting and then copies from Row 1 to the end row but only columns A:J. The macro returns to the first workbook and pastes those numbers by pressing enter into Cell A7. The problem is that two things can happen. The rows can be the same number as the month before or can increase by 1 or more rows. What I cannot figure out is how to get the columns from K:AM to copy and past those formulas down to the bottom row, which could be the same as before or more. Hopefully this makes sense.
 
Last edited:

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Hi Papi,

If I understand you correctly, you could:
Get the last row in Column A
Get the last row in Column K.
If Last Row K > Last Row Then copy your formulas from Last Row K+1 to Last Row A.

On what row are your formulas for K:AM always located?
 
Upvote 0
Thanks JS411,

This is something like the data looks like. The example shows four addition items from the other workbook and places them from Row A6 to J15, The issue is trying to get the last four (or more or less or the same) from K12:AM15 as those are all formulas.

Purchases.xlsm
ABCDEFGHIJKLMNO
5TotalMainSecondHardwareFastenerWoodHousewaresElectricalMisc2011AlbertaDWBen'sCanyon
6Customer583761125 2422109100 
7AlbertaDrywall613116AlbertaDrywall6  
8Ben'sBicycles2112Ben'sBicycles100  
9CanyonMeadowsElectrical121132144CanyonMeadowsElectrical 100 
10DeerfootDriveInn31113DeerfootDriveInn3  
11ErnstLithographers71247ErnstLithographers   
12FrontPorchDesign7124
13JavaJavaPath7124
14KirchensPlus7124
15Larken'sBooks&Mags7124
Main
 
Upvote 0
Try...
Code:
Sub Fill_Formulas()
    Dim lLastRowColA As Long, lLastRowColK As Long
    
    '---get last row of Columns A and K
    lLastRowColA = Range("A" & Rows.Count).End(xlUp).Row
    lLastRowColK = Range("K" & Rows.Count).End(xlUp).Row
    If lLastRowColA <= lLastRowColK Then Exit Sub
    
    '---copy down
    With Range("K" & lLastRowColK & ":AM" & lLastRowColK)
        .Copy Destination:=.Offset(1, 0) _
            .Resize(lLastRowColA - lLastRowColK)
    End With
End Sub
 
Upvote 0
Hello Jerry,

In simple terms it works perfectly. Thanks for your time and effort. It is truly appreciated.

Alan
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,678
Members
452,937
Latest member
Bhg1984

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top