VB: default cell formula

rnation

New Member
Joined
Mar 18, 2010
Messages
7
Is there a way to assign column cells a formula that references other cells in VB. I have gotten around this by running a macro that copies the previous cell formula from above and pasting it on line below. that method has flaws that I can no longer use.

The idea is to make cell C2 = B2*A2... and C3 = B3*A3, but having VB assign the formulas. Row 1 is all column titles so VB would have to omit row 1 from the formula as well.

Help!
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
If I understand you correctly (and I am not sure that I do), I think the following should work for you.

Let's say that you wanted to populate C2 through C10 with a formula that multiples column A in that same row by column B. This simple one-line VBA code would do that:
Range("C2:C10").FormulaR1C1 = "=RC[-2]*RC[-1]"

Is that what you are looking for?
 
Upvote 0
If I understand you correctly (and I am not sure that I do), I think the following should work for you.

Let's say that you wanted to populate C2 through C10 with a formula that multiples column A in that same row by column B. This simple one-line VBA code would do that:
Range("C2:C10").FormulaR1C1 = "=RC[-2]*RC[-1]"

Is that what you are looking for?

The formula will be more difficult than that, but yes. The idea is to write a formula to lookup the description (from another spreadsheet) of a product by using the product# in column C. Over time some products may get added or may be discontinued, so there will be new numbers that are referenced or product numbers that have been taken out. So if the Product# is in Column C of the reference spreadsheet then that Description should be used, otherwise if the product# is no longer used then lookup existing description.

I hope this helps clarify, but I am not sure it does.
 
Upvote 0
Instead of trying to simplify it, why not tell us exactly what you want, complete with data examples? The more details you provide, the better the solution will probably be.
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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