View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_3_] Dave Peterson[_3_] is offline
external usenet poster
 
Posts: 2,824
Default Macro to enter formula with text

Depending on where you're putting the formula, maybe you can use something like:

=COUNTIF(A$2:A$374,"RM"&TEXT(ROW()+1,"00"))

But watch out if you add rows!

If you really want them hardcoded in your formula, you could use a formula like:

="=COUNTIF(A$2:A$375,""RM"&TEXT(ROW()+1,"00")&""") "
and drag down.

This'll return a string that looks like your formula.
copy|paste special|values
then Edit|replace
= (equal sign)
with
= (equal sign)

and excel will see it them as formulas again and reevaluate.

bambam77 wrote:

For some reason when I execute my macro, my formulas which include text
won't update unless I select the cell and then click in the formula bar
and then hit enter. It was suggested by someone here to therefore
create a macro that will re-install the formulas.

Is there a way to write code to install a formula like this for several
cells : =COUNTIF(A$2:A$374,"RM01"). The only thing that changes in the
formula is the text. For each cell the text changes by a value of 1.

For example:
=COUNTIF(A$2:A$374,"RM02")
=COUNTIF(A$2:A$374,"RM03")
=COUNTIF(A$2:A$374,"RM04").........and so on.

Is there some kind of loop or something I can use to make writing this
code less tedious???

Thanks and Happy new year.

---
Message posted from http://www.ExcelForum.com/


--

Dave Peterson