Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Using a macro to do a calculation

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.a...mming/200708/1

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Using a macro to do a calculation

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.

bhrosey via OfficeKB.com wrote:
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.a...mming/200708/1


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Using a macro to do a calculation

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.

JW wrote:
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]
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200708/1


--
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 http://www.officekb.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Using a macro to do a calculation

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

without this line, the formula will go in the currently selected cell
--
Gary''s Student - gsnu200740


"bhrosey via OfficeKB.com" wrote:

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.a...mming/200708/1


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Using a macro to do a calculation

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 wrote:
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.a...mming/200709/1



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
If VBA Macro for Tiered Calculation Jeff Excel Discussion (Misc queries) 2 February 17th 09 04:35 PM
Macro Help for a BIG Calculation Ananth Excel Discussion (Misc queries) 1 July 27th 07 09:29 AM
Product calculation macro MikeD1224 New Users to Excel 1 June 15th 07 10:36 PM
MACRO TO SET THE AUTOMATIC CALCULATION OB Excel Discussion (Misc queries) 2 November 15th 06 05:36 PM
Run a macro when cell changes (due to calculation!) Tornados Excel Programming 3 December 23rd 03 04:16 PM


All times are GMT +1. The time now is 02:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"