I am creating a piece of VBa code which will insert a specific formula into my worksheet. As the file is in a shared dropbox I want to create a filepath with a string thisworkbook.path. Though I am unable to use this string in my formula.
The formula that need be pasted is a SUMIF Formula, taking data from another sheet in my workbook, though it keeps asking for a file directory when i try to insert the formula
Sub Monthly_OTB_update()
'
Dim I As Long
Dim J As Integer
Dim H As Integer
Dim A As String
Dim B As String
Dim C As String
Dim D As String
Dim E As String
A = ThisWorkbook.Path
B = "2019"
C = "Monthly OTB 2019"
D = A & B
E = A & C
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.DisplayStatusBar = False
'Go to Last used date and select the next cell
Sheets("Monthly OTB 2019").Select
Range("E2").Select
Selection.End(xlToRight).Select
ActiveCell.Offset(0, 1).Select
For I = 1 To 12
'Fill selection with date and move 1 down
ActiveCell.FormulaR1C1 = "=TODAY()"
ActiveCell.Offset(1, 0).Select
'insert formula to retrieve data
ActiveCell.FormulaR1C1 = _
"=SUMIFS("" & D & ""!R4C5:R100000C5,OTB!R4C2:R100000C5,"" & E & ""!RC1)"
I did not include the full code as the rest is just repetition of what happens in the code that is here. and the end of the loop & Sub.
The error that pops up is application or object defined error.