Need help Copying down a formula to the bottom of a list in VBA

dragontbone

New Member
Joined
Sep 28, 2022
Messages
37
Office Version
  1. 365
Platform
  1. Windows
So im trying to get a formula to copy down using VBA. I have it mostly working, however, it won't copy the formula down to the last cell. Im trying to make it dynamic enough to copy the formula down to the bottom of a list that changes all the time. It's having issues in cell I15.

VBA Code:
Sub offsetCreditAmount()

    ' This will add the concatenate formula for credit amount

    Dim DateCountCalculator As Integer
    Dim MinusStart As Range
    Range("I8").Select
    DateCountCalculator = Range("DateCountCalculator").Value



    Set MinusStart = Range("Start_Date_Calculator").offset(-1, 7)
    
    MinusStart.Resize(Range("DateCountCalculator")).FormulaR1C1 = _
          "=OFFSET(ConcatenateDateStart,ROWS(R1C12)-2,0) &RC[-1]"
     


End Sub


SFBillingSuperToolv7.V16.xlsm
ABCDEFGHIJKL
18
2
3
4
5
6List InputDate Output Credit Amount Output
7
8Water for 06/11/227/13/2022-Water for 06/11/22 - 07/13/2022Water for 06/11/22 - 07/13/2022$277.75277.75277.75
9Sewer for 06/11/227/13/2022-Sewer for 06/11/22 - 07/13/2022Sewer for 06/11/22 - 07/13/2022$261.17261.17261.17
10Water for 07/14/228/9/2022-Water for 07/14/22 - 08/09/2022Water for 07/14/22 - 08/09/2022$417.43417.43417.43
11Sewer for 07/14/228/9/2022-Sewer for 07/14/22 - 08/09/2022Sewer for 07/14/22 - 08/09/2022$369.19369.19369.19
12Trash for 07/14/228/9/2022-Trash for 07/14/22 - 08/09/2022Trash for 07/14/22 - 08/09/2022$12.6012.612.6
13Electric for 07/14/228/9/2022-Electric for 07/14/22 - 08/09/2022Electric for 07/14/22 - 08/09/2022$257.60257.6257.6
14Vacant Service for 07/14/228/9/2022-Vacant Service for 07/14/22 - 08/09/2022Vacant Service for 07/14/22 - 08/09/2022$50.005050
15Gas for 07/14/228/9/2022-Gas for 07/14/22 - 08/09/2022Gas for 07/14/22 - 08/09/2022$20.35
16
17
18
19
20
21
22
23
24
Date Credit Calculator
Cell Formulas
RangeFormula
L1L1=COUNTIF(DateCalculatorRange,"*")
I7:I14I7=OFFSET(ConcatenateDateStart,ROWS($L$1)-2,0) &H7
F8:F15F8=OFFSET(Start_Date_Calculator,ROWS($A$1:$A1)-1,0) & " - " & TEXT(C8,"MM/DD/YYYY")
Named Ranges
NameRefers ToCells
AmountStart='Date Credit Calculator'!$H$8I8
ConcatenateDateStart='Date Credit Calculator'!$D$8I7:I14
DateCalculatorRange='Date Credit Calculator'!$B$8:$B$1006F8:F15, L1
DateCountCalculator='Date Credit Calculator'!$L$1I7:I14
Start_Date_Calculator='Date Credit Calculator'!$B$8F8:F15, L1
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Try changing the -1 in this line to 0
VBA Code:
 Set MinusStart = Range("Start_Date_Calculator").offset(-1, 7)
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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