convert excel formula to vba

Scott13

New Member
Joined
Dec 29, 2015
Messages
31
SO I have the following formula:

Code:
=IFERROR(IF(AND(B$8>=(VLOOKUP($A9,Leave_Dates,2,FALSE)), (B$8<=(VLOOKUP($A9,Leave_Dates,3,FALSE))),WEEKDAY(B$8,1)<6), "L", ""), "")

I need to somehow convert this to VBA to perform the same thing.

"Leave_Dates" is a named table
B8:AF8 contains dates of the month ( 1 jan thru 31 jan)
A9:A16 contains names of employees
 
E27 works too the formula is relative, but, you have to be in E27 it works on the selected cell
 
Last edited:
Upvote 0

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
E27 works too the formula is relative, but, you have to be in E27 it works on the selected cell

Having to be in a specific cell is not what I was after. What I would like is when A7 has X and E19 has X then E27 would automatically have an X. Second part is if E7 has X and E19 has X then E27 would again have autofill X.

For me, simply adding the Xs to A7 and E19 does nothing, even if I have E27 selected. If I run macro1 from Macros list I get a Compile error: Syntax error
 
Upvote 0
If you want to be in E27 change the macro to
Code:
Sub Macro1()
'
' Macro4 Macro
'

'
    Range("E27").Select
    ActiveCell.FormulaR1C1 = _
        "=IF(AND(R[-20]C[-4]=""X"",R[-8]C=""X""),""X"",IF(AND(R[-20]C=""X"",R[-21]C= ""F9EX Ey II"", R[-8]C=""X""),""X"",IF(AND(R[-20]C=""X"",R[-21]C=""F9DX EY II"", R[-8]C=""X""),""X"","""")))"
    Range("E28").Select
End Sub
This works only for E27
Cheers
Sergio
 
Upvote 0
OK, this one works perfectly for what I need. I really appreciate all your help Sergio. I never would have figured this out myself.
 
Upvote 0

Forum statistics

Threads
1,214,786
Messages
6,121,546
Members
449,038
Latest member
Guest1337

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