Inputting a formula with a Macro

P

prozewski

I am running a macro that copies and pastes different reports into one
workbook (each on a different sheet) and then does some formatting and
formula calculations on each sheet. I then reference all of those sheets onto
a summary page. I am currently having an issue with one of my formulas. Here
is the formula:

Range("B3").Select
ActiveCell.FormulaR1C1 = "=(Class_" & i & "_Name)"
The "i" is a variable that changes depending on which sheet is being worked
on. The formula works, but only to a point. The cell named "Class_1_Name" has
a formula to Concatenate other cells on the summary page once they are filled
in. They aren't filled in until after the macro is done running (they are
filled manually). Currently what is happening is the value that is
"Class_1_Name" is being inputted into cell B3 on the current worksheet. I
actually want cell B3 to have in it "=Class_1_Name", not just what that cell
contains when it the macro runs. With all of my other formulas, they actually
appear in the cell when you click on it, but for whatever reason, I can't get
the actual formula to appear in this cell. I even tried to do the formula for
the concatenation that I do on the summary page and it does the same thing.
How do I get the actual formula to go into the cell, so that when the
contents of the cells that are referenced change, the cell on the worksheet
changes?

Please let me know this makes sense. Any help is appreciated.
Thanks,
Paul
 
S

Sheeloo

Your problem is not clear..

If i is 1 then your code will enter the following in B3
=(Class_1_Name)
and this is what you would see in the formula box

The cell will show the value in the cell named Class_1_Name, so if that cell
has the formula
=3+4

B3 will show 7... If you fill Class_1_Name later it will show 0 till then.
If name is not defined then it will show #Name error till name is defined...
 
P

prozewski

Unfortunately when I look in the formula box after the macro runs, all it has
is what was in the cell named Class_1_Name at the time the macro ran, not
=(Class_1_Name), which is really what I want. How do I get this to show up in
the formula bar?
Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top