Formula giving Run Time Error

WxShady13

Board Regular
Joined
Jul 24, 2018
Messages
184
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
I am trying to post the below code into a column of a table so that it will determine if an employee is Valid or Not Valid when it comes to whether or not they accrue vacation. When I paste this formula into a VBA script I get a Run-Time 1004 error. I cannot determine why...The worksheet name is correct and security has been removed.

Code:
Worksheets("Lost Time Records").Range("J2:J120").Formula = "=IF(And(I2>1/1/1950,I2<$M$24)""Valid"",""Not Valid"")"
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
The formula itself is invalid. There needs to be a comma after the and.

"=IF(And(I2>1/1/1950,I2<$M$24),""Valid"",""Not Valid"")"
 
Upvote 0
I just made myself type "I will not write VBA code without at least 4 cups of coffee" on the white board :D Thank you so much for catching that!!!! You rock
 
Upvote 0
The trick I use when confronted with this problem is to remove the equals in the VBA so that the VBA writes a text string. Then go to the cell and add the equals sign back in, EXCEL will then kindly tell where the problem is
 
Upvote 0

Forum statistics

Threads
1,215,056
Messages
6,122,907
Members
449,096
Latest member
dbomb1414

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