Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
PJ PJ is offline
external usenet poster
 
Posts: 112
Default Paste VBA formula into cell

I have a VBA macro which determines various ranges of cells that need to be
analyzed and assigns the ranges to different values, such as wrkRng. The
line below does partially what I need. It calculates correctly and puts the
value I'm looking for in the specified cell.

Range("B6").Select
ActiveCell.FormulaR1C1 = Evaluate("=COUNTIF(" & wrkRng.Address & ",""1"")")

The problem I have is the macro needs to be run I need to run the macro
before all of the cells have been updated. What I need is for the code to
put the actual formula in the cell so it is recalculated as the cells are
updated later and not the value from when it is initially run.

Since the ranges vary I can't just hard code the formula. But if wrkRng
happened to be D8:I25 at the time the macro was run, I want have this formula
entered into cell B6:

=COUNTIF($D$8:$I$25, "1")
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Paste VBA formula into cell

You have a reply at your earlier post.

PJ wrote:

I have a VBA macro which determines various ranges of cells that need to be
analyzed and assigns the ranges to different values, such as wrkRng. The
line below does partially what I need. It calculates correctly and puts the
value I'm looking for in the specified cell.

Range("B6").Select
ActiveCell.FormulaR1C1 = Evaluate("=COUNTIF(" & wrkRng.Address & ",""1"")")

The problem I have is the macro needs to be run I need to run the macro
before all of the cells have been updated. What I need is for the code to
put the actual formula in the cell so it is recalculated as the cells are
updated later and not the value from when it is initially run.

Since the ranges vary I can't just hard code the formula. But if wrkRng
happened to be D8:I25 at the time the macro was run, I want have this formula
entered into cell B6:

=COUNTIF($D$8:$I$25, "1")


--

Dave Peterson
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
Paste VBA formula in cell PJ Excel Programming 2 February 14th 09 02:51 AM
Paste A Cell Formula Into A Cell With A Macro. Minitman Excel Worksheet Functions 0 March 26th 08 04:50 AM
formula won't paste from one cell to another with current cell inf kentndebra Excel Worksheet Functions 1 August 22nd 06 04:52 PM
How do I sum a formula and paste it in 7 cell increments? ExcelQuestionStephen Excel Discussion (Misc queries) 4 April 9th 05 07:12 AM
Copy paste formula up to a cell using VBA Angeliki Excel Programming 2 September 25th 03 04:11 AM


All times are GMT +1. The time now is 06:39 PM.

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

About Us

"It's about Microsoft Excel"