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 in 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: 3,101
Default Paste VBA formula in cell

Try this
ActiveCell.Formula = "=COUNTIF(" & wrkRng.Address & ",""1"")"


"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")

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default Paste VBA formula in cell

Why would you not post the entire code?
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 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 to paste formula but reference a fixed cell HR Excel Discussion (Misc queries) 3 April 7th 06 04:27 AM
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 09:03 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"