How to find the last non-empty and enter a formula of a range of cells from the next row and on?

DreyFox

Board Regular
Joined
Nov 25, 2020
Messages
61
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I have Sheet1 with the following table
1635260432097.png

I need a VBA code that I would put in a button which would find the last non empty cell in the 1st column, which would be A14, then offset by 1 to the next cell below. Then I would like to insert formula from that cell to cell B40.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Something like this
VBA Code:
Sub DreyFox()
Dim lRow As Long, rng As Range

    lRow = Cells(Rows.Count, 1).End(xlUp).Row

    Set rng = Range(Cells(lRow + 1, 2), "B40")
    Rng.Formula = "your formula goes here"
End Sub
 
Upvote 0
Something like this
VBA Code:
Sub DreyFox()
Dim lRow As Long, rng As Range

    lRow = Cells(Rows.Count, 1).End(xlUp).Row

    Set rng = Range(Cells(lRow + 1, 2), "B40")
    Rng.Formula = "your formula goes here"
End Sub
Hi Jason,

Thanks for the response. That kind of works, however, I need column A to have the formulas as well. Currently, it seems to only add the formulas to column B. Pleas advise me. Thank you.

Drey
 
Upvote 0
Easy enough, I just misread the offset ask in your post.
VBA Code:
Sub DreyFox()
Dim lRow As Long, rng As Range

    lRow = Cells(Rows.Count, 1).End(xlUp).Row

    Set rng = Range(Cells(lRow + 1, 1), "B40")
    Rng.Formula = "your formula goes here"
End Sub
 
Upvote 0
Solution
Easy enough, I just misread the offset ask in your post.
VBA Code:
Sub DreyFox()
Dim lRow As Long, rng As Range

    lRow = Cells(Rows.Count, 1).End(xlUp).Row

    Set rng = Range(Cells(lRow + 1, 1), "B40")
    Rng.Formula = "your formula goes here"
End Sub
That works as intended. Thank you so much :)
 
Upvote 0

Forum statistics

Threads
1,215,003
Messages
6,122,655
Members
449,091
Latest member
peppernaut

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