Hi VBA masters,
I'm creating an automated daily income statement with currency rates, cash balances, expenses, etc. I would like to add a monthly column that's dynamic and uses VBA's ".Formula" tool to add functions and perform calculations on the daily values. I'm having trouble using the .End(xlToRight) technique to make it dynamic. Here are some pieces of what I have so far:
When I run the above code, I get a "Run-time error '13': Type mismatch" ... when I hardcode the range, such as "=AVERAGE(D5:G5)", it works. Any help on this issue would be great!
Thanks!
I'm creating an automated daily income statement with currency rates, cash balances, expenses, etc. I would like to add a monthly column that's dynamic and uses VBA's ".Formula" tool to add functions and perform calculations on the daily values. I'm having trouble using the .End(xlToRight) technique to make it dynamic. Here are some pieces of what I have so far:
PHP:
Dim homecell as object
Dim CCYrange As Object
Set homeCell = Range("D5")
Set CCYrange = Range(Range("D5"), Range("D5").End(xlToRight))
homecell.Offset(4, 10).Formula = "=AVERAGE(" & CCYrange & ")"
When I run the above code, I get a "Run-time error '13': Type mismatch" ... when I hardcode the range, such as "=AVERAGE(D5:G5)", it works. Any help on this issue would be great!
Thanks!