dragontbone
New Member
- Joined
- Sep 28, 2022
- Messages
- 37
- Office Version
- 365
- Platform
- 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 | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | |||
1 | 8 | |||||||||||||
2 | ||||||||||||||
3 | ||||||||||||||
4 | ||||||||||||||
5 | ||||||||||||||
6 | List Input | Date Output | Credit Amount Output | |||||||||||
7 | ||||||||||||||
8 | Water for 06/11/22 | 7/13/2022 | - | Water for 06/11/22 - 07/13/2022 | Water for 06/11/22 - 07/13/2022 | $277.75 | 277.75 | 277.75 | ||||||
9 | Sewer for 06/11/22 | 7/13/2022 | - | Sewer for 06/11/22 - 07/13/2022 | Sewer for 06/11/22 - 07/13/2022 | $261.17 | 261.17 | 261.17 | ||||||
10 | Water for 07/14/22 | 8/9/2022 | - | Water for 07/14/22 - 08/09/2022 | Water for 07/14/22 - 08/09/2022 | $417.43 | 417.43 | 417.43 | ||||||
11 | Sewer for 07/14/22 | 8/9/2022 | - | Sewer for 07/14/22 - 08/09/2022 | Sewer for 07/14/22 - 08/09/2022 | $369.19 | 369.19 | 369.19 | ||||||
12 | Trash for 07/14/22 | 8/9/2022 | - | Trash for 07/14/22 - 08/09/2022 | Trash for 07/14/22 - 08/09/2022 | $12.60 | 12.6 | 12.6 | ||||||
13 | Electric for 07/14/22 | 8/9/2022 | - | Electric for 07/14/22 - 08/09/2022 | Electric for 07/14/22 - 08/09/2022 | $257.60 | 257.6 | 257.6 | ||||||
14 | Vacant Service for 07/14/22 | 8/9/2022 | - | Vacant Service for 07/14/22 - 08/09/2022 | Vacant Service for 07/14/22 - 08/09/2022 | $50.00 | 50 | 50 | ||||||
15 | Gas for 07/14/22 | 8/9/2022 | - | Gas for 07/14/22 - 08/09/2022 | Gas for 07/14/22 - 08/09/2022 | $20.35 | ||||||||
16 | ||||||||||||||
17 | ||||||||||||||
18 | ||||||||||||||
19 | ||||||||||||||
20 | ||||||||||||||
21 | ||||||||||||||
22 | ||||||||||||||
23 | ||||||||||||||
24 | ||||||||||||||
Date Credit Calculator |
Cell Formulas | ||
---|---|---|
Range | Formula | |
L1 | L1 | =COUNTIF(DateCalculatorRange,"*") |
I7:I14 | I7 | =OFFSET(ConcatenateDateStart,ROWS($L$1)-2,0) &H7 |
F8:F15 | F8 | =OFFSET(Start_Date_Calculator,ROWS($A$1:$A1)-1,0) & " - " & TEXT(C8,"MM/DD/YYYY") |
Named Ranges | ||
---|---|---|
Name | Refers To | Cells |
AmountStart | ='Date Credit Calculator'!$H$8 | I8 |
ConcatenateDateStart | ='Date Credit Calculator'!$D$8 | I7:I14 |
DateCalculatorRange | ='Date Credit Calculator'!$B$8:$B$1006 | F8:F15, L1 |
DateCountCalculator | ='Date Credit Calculator'!$L$1 | I7:I14 |
Start_Date_Calculator | ='Date Credit Calculator'!$B$8 | F8:F15, L1 |