VBA Formula

zinah

Active Member
Joined
Nov 28, 2018
Messages
353
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have below formulas and I need someone to help me writing it as VBA formula:

Code:
=IF($Y$16 = "by Loc", INDIRECT($AC$14), $Z$15)

Code:
=IF($Y$16 = "by Loc", IF(ROW(INDIRECT($AC$14)) + COUNTA($Y$18:$Y18) > ROW(INDIRECT($AC$15)), "", OFFSET(INDIRECT($AC$14), COUNTA($Y$18:$Y18), 0)),
IF($Z$15 + COUNTA($Y$18:$Y18) > $AA$15, "", $Z$15 + COUNTA($Y$18:$Y18)))

Thanks
 

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"
Hi Zinah

Try This
Code:
Sub EnterFormula()
    Range("A1") = "=IF($Y$16 = ""by Loc"", INDIRECT($AC$14), $Z$15)"
    Range("A2").Formula = "=IF($Y$16 = ""by Loc"", IF(ROW(INDIRECT($AC$14)) + COUNTA($Y$18:$Y18) > ROW(INDIRECT($AC$15)), """", OFFSET(INDIRECT($AC$14), COUNTA($Y$18:$Y18), 0)),IF($Z$15 + COUNTA($Y$18:$Y18) > $AA$15, """", $Z$15 + COUNTA($Y$18:$Y18)))"
End Sub

Remember it shoul be """" not "", four Quotation marks, not two, always double :)
 
Last edited:
Upvote 0
Hi
Sahak

Thank you so much for your help, I need more favor please with below formula, I have range [X18:X42] need to update this formula to manage populating all the formulas starting from row 18 to 42, how can I do that?

Code:
.Formula = "=IFERROR(1-(AD18/AC18)," & Chr(34) & Chr(34) & ")"
 
Last edited:
Upvote 0
USe

Code:
Range("X18:X42").Formula = "=IFERROR(1-(AD18/AC18),IFERROR(1-(AD18/AC18),""""))"
 
Upvote 0
Hi Zinah,

I'm sorry for late reply, I just came home. I'm happy that I could help you. Your second question also answered correctly & this time by Michael M
 
Upvote 0
Thank you
That really helped, but when I wanted to turn the formula to value by using below, it didn't work, can you please advise what should I do?

Code:
.Value = .Value
 
Upvote 0
No worries Sahak

I really appreciate your time and support, I'm new to VBA and trying my best to learn this amazing language :), I have another formula which can give similar result as the one you suggested but I need to add .Row, however, I'm not sure what I'm missing:
Code:
.Formula = "=IFERROR(1-(AD" & .row "& /"AC & .row)," & Chr(34) & Chr(34) & ")"
 
Upvote 0

Forum statistics

Threads
1,213,517
Messages
6,114,085
Members
448,548
Latest member
harryls

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