Solved

Replace Formula

Posted on 2014-01-21
8
196 Views
Last Modified: 2014-01-22
How can I replace  "=RC[-10]*RC[-5]"
with  

 "=IFERROR(VLOOKUP(TODAY(),Holidays!B$2:D$9,3,0),1)*E13*J13"



>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

 Range("O10").FormulaR1C1 = "Day's Total Earned Inc"
        Range("O11:O" & row - 1).FormulaR1C1 = "=RC[-10]*RC[-5]"
        Range("O11:O" & row - 1).Style = "Comma"  


 "=IFERROR(VLOOKUP(TODAY(),Holidays!B$2:D$9,3,0),1)*E13*J13"
0
Comment
Question by:leezac
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 14

Expert Comment

by:brendanmeyer
ID: 39798937
Range("O10").FormulaR1C1 = "Day's Total Earned Inc"
        Range("O11:O" & row - 1).FormulaR1C1 = "=IFERROR(VLOOKUP(TODAY(),Holidays!B$2:D$9,3,0),1)*E13*J13"
        Range("O11:O" & row - 1).Style = "Comma"   

Open in new window



Is this what you are wanting? Or how are you trying to replace it?
0
 

Author Comment

by:leezac
ID: 39798951
That is what I was thinking, but the old formula uses  "=RC[-10]*RC[-5]"


I need  "=IFERROR(VLOOKUP(TODAY(),Holidays!B$2:D$9,3,0),1)*E13*J13"
to be entered starting at O11

The formula works if I add to a cell manually.  But the former code enters it using vba using just
"=RC[-10]*RC[-5]"
but I needed to modify it thus the new formula but not sure how to add it.  Why I am posting.
0
 
LVL 81

Expert Comment

by:byundt
ID: 39799107
Try:
Range("O11:O" & row - 1).FormulaR1C1 = "=IFERROR(VLOOKUP(TODAY(),Holidays!R2C[-13]:R9C[-11],3,0),1)*R[2]C[-10]*R[2]C[-5]"

Open in new window


Note that the formula in O11 will be looking at values in E13 and J13 (i.e. two rows lower).
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

Author Comment

by:leezac
ID: 39800052
That did not work - I am attaching a sample file.  I need to use If Active sheet.name etc.

I need the formula to copy down column starting at O11.


The formula checks for Todays date on the Holiday Table

Thanks
ee---workdays-multipliers--2-.zip
0
 
LVL 81

Expert Comment

by:byundt
ID: 39800154
You need to define a value for the variable Row in your macro.

Also, ActiveSheet is a VBA keyword that points to the worksheet that is currently active. You don't need to Dim it.

The code snippet below fixes both problems and illustrates how to put the formulas in column O two ways: one using R1C1 notation as requested, and another using A1 notation that you may find easier to understand.
Sub Enterformula()
Dim Row As Long
Row = 15
If Activesheet.Name = "Variance Check" Then
        Range("O10").FormulaR1C1 = "Day's Total Earned Inc"
        
        'Set formulas in column O using R1C1 notation
        Range("O11:O" & Row - 1).FormulaR1C1 = "=IFERROR(VLOOKUP(TODAY(),Holidays!R2C[-13]:R9C[-11],3,0),1)*R[2]C[-10]*R[2]C[-5]"
        
        'Set formulas in column O using A1 notation
        Range("O11:O" & Row - 1).Formula = "=IFERROR(VLOOKUP(TODAY(),Holidays!B$2:D$9,3,0),1)*E13*J13"
        
        Range("O11:O" & Row - 1).Style = "Comma"
    End If

End Sub

Open in new window

0
 

Author Comment

by:leezac
ID: 39800258
Thank you - Iam working on adding the above

I also need if I use this formula then if there is no match to Today's date then  it still multiplies  E13*J13.

Range("O11:O" & row - 1).Formula = "=IFERROR(VLOOKUP(TODAY(),Holidays!B$2:D$9,3,0),1)*E11*J11"
0
 
LVL 81

Accepted Solution

by:
byundt earned 500 total points
ID: 39800282
When you set the .Formula property, make sure that the formula text is appropriate for the first cell in the range (O11). Excel VBA will handle the relative and absolute addressing bits for the other cells in the range.

Should the formula for row 11 be using E13*J13 or E11*J11? Your most recent Comment talks about both.

The IFERROR will return either a value from column D in Holidays worksheet or 1. So either way you get something to multiply by the product of column E and J.
0
 

Author Comment

by:leezac
ID: 39800322
It should be E11*J11
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question