XL 2003 Question

pullmyefinger

Board Regular
Joined
Mar 9, 2011
Messages
69
ActiveCell.Formula = "=IF(AND('A'&EmptyRow>0,'B'&EmptyRow>0),'A'&EmptyRow-'A'&NewRow,0)"

This should be ez but it is giving me problems. App or Object-Defined error in a VB macro.

Just trying to create a formula to calculate the number of days for an interest payment. I can't hard code the payment date or the cell that contains the last date of payment. I figured

I could use ActiveCell to put a formula in the correct cell once I have all the other necessary info in other cells.

The formula needs to be =IF(AND(A9>0, B9>0), A9-A6,0) where

- EmptyRow is a variable that contains the next empty row where the new payment is to go.
- (Row) 9.
- NewRow is a variable that contains the row value of the last payment. (row) 6.
- The 6 is pasted as a value in cell O6 prior.
- The contents of column A are both date values, so I need A9-A6 to give me a value such as 29.

- I have to be doing something stupid cuz this is not a big deal.


This is what is in the macro now that is giving me the error:

ActiveCell.Formula = "=IF(AND('A'&EmptyRow>0,'B'&EmptyRow>0),'A'&EmptyRow-'A'&NewRow,0)"

What the heck am I doing wrong?
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Allow the variables to be calculated:

Code:
Sub qwerty()
   EmptyRow = 9
   NewRow = 6
   ActiveCell.Formula = "=IF(AND(A" & EmptyRow & ">0,B" & EmptyRow & ">0),A" & EmptyRow & "-A" & NewRow & ",0)"
End Sub
 
Upvote 0

Forum statistics

Threads
1,202,962
Messages
6,052,821
Members
444,602
Latest member
Cookaa

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