Using a macro to do a calculation

  • Thread starter bhrosey via OfficeKB.com
  • Start date
B

bhrosey via OfficeKB.com

I have the following macro, but how do make it so it will do the calculation
for any cell I select instead of just the original cell?

Range("F14").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-4]=""nv71pull"",(RC[-1]/192),(RC[-1]
/150))"

Thanks in advance for the help

Bill R.
God Bless

--
John 3:16 "For God so loved the world that He gave His only begotten Son, so
that whoever believes in Him shall not parish, but have eternal life"

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/excel-programming/200708/1
 
J

JW

Just take out the Range("F14").Select statement and the formula will
be placed in the active cell. If you need to loop through a range and
pug in that formula, look at using a For...Next loop.
 
G

Guest

Just remove the:
Range("F14").Select

without this line, the formula will go in the currently selected cell
 
B

bhrosey via OfficeKB.com

How would I do this for a group of cells? For example: I want to highlight
cells F14 : F26 and perform the same calculation in each of those cells.
Just take out the Range("F14").Select statement and the formula will
be placed in the active cell. If you need to loop through a range and
pug in that formula, look at using a For...Next loop.
I have the following macro, but how do make it so it will do the calculation
for any cell I select instead of just the original cell?
[quoted text clipped - 14 lines]
 
B

bhrosey via OfficeKB.com

It's only doing the calculation for first cell of the highlighted group.
Here is the way my code looks now.

Sub calculatepallets()
ActiveCell.FormulaR1C1 = "=IF(RC[-4]=""nv71pull"",(RC[-1]/192),(RC[-1]
/150))"
End Sub

Thanks

Gary''s Student said:
Just remove the:
Range("F14").Select

without this line, the formula will go in the currently selected cell
I have the following macro, but how do make it so it will do the calculation
for any cell I select instead of just the original cell?
[quoted text clipped - 7 lines]
Bill R.
God Bless

--
John 3:16 "For God so loved the world that He gave His only begotten Son, so
that whoever believes in Him shall not parish, but have eternal life"

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/excel-programming/200709/1
 

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