PC Review


Reply
Thread Tools Rate Thread

Can I insert formulas into my macros?

 
 
Sarah
Guest
Posts: n/a
 
      3rd Apr 2008
I tried recording some formulas into a macro, but this doesn't work. Is it
possible to do so, without using Visual Basic programming? Can it be done
using Visual Basic programming - I am not an expert :-)
 
Reply With Quote
 
 
 
 
Mike H
Guest
Posts: n/a
 
      3rd Apr 2008
Sarah,

You can record formula entry with the macro recorder:-
ActiveCell.Formula = "=SUM(A3:A9)"
ActiveCell.FormulaR1C1 = "=SUM(RC[-1]:R[6]C[-1])"

These 2 formula are the same, they are in B3 and add up A3 to A9. The first
is entered manually and the second is the recorded version of the same thing.

What precisely are you trying to do?


Mike


"Sarah" wrote:

> I tried recording some formulas into a macro, but this doesn't work. Is it
> possible to do so, without using Visual Basic programming? Can it be done
> using Visual Basic programming - I am not an expert :-)

 
Reply With Quote
 
Sarah
Guest
Posts: n/a
 
      3rd Apr 2008
Hi Mike,

Thanks for your quick answer ! In fact, I tried recording the copying a
formula I created earlier in another workbook (this one below)

=IF(ISERROR(LEFT(F2;FIND(200;F2)-1));F2;(LEFT(F2;FIND(200;F2)-1)))
it replaces a word, with a number after the word starting by 200, by only
the word

because I always have to do this when I create the updated version of the
same report.

Are you saying that it is necessary to insert the formula manually for it to
be recorded by a macro, and that I can not copy the formula from another
worksheet?

Sarah

"Mike H" wrote:

> Sarah,
>
> You can record formula entry with the macro recorder:-
> ActiveCell.Formula = "=SUM(A3:A9)"
> ActiveCell.FormulaR1C1 = "=SUM(RC[-1]:R[6]C[-1])"
>
> These 2 formula are the same, they are in B3 and add up A3 to A9. The first
> is entered manually and the second is the recorded version of the same thing.
>
> What precisely are you trying to do?
>
>
> Mike
>
>
> "Sarah" wrote:
>
> > I tried recording some formulas into a macro, but this doesn't work. Is it
> > possible to do so, without using Visual Basic programming? Can it be done
> > using Visual Basic programming - I am not an expert :-)

 
Reply With Quote
 
Mike H
Guest
Posts: n/a
 
      3rd Apr 2008
Sarah,

I can see what you formula does but I'm not sure what the question is, take
these 2 examples

Range("F3").Formula =
"=IF(ISERROR(LEFT(F2,FIND(200,F2)-1)),F2,(LEFT(F2,FIND(200,F2)-1)))"

Range("F3").Formula = Sheets("Sheet1").Range("F5").Formula

The first puts you formula into F3 and the second copies your fromula from
F5 to F3
Note i've changed ; to , for my version of Excel

Mike

"Sarah" wrote:

> Hi Mike,
>
> Thanks for your quick answer ! In fact, I tried recording the copying a
> formula I created earlier in another workbook (this one below)
>
> =IF(ISERROR(LEFT(F2;FIND(200;F2)-1));F2;(LEFT(F2;FIND(200;F2)-1)))
> it replaces a word, with a number after the word starting by 200, by only
> the word
>
> because I always have to do this when I create the updated version of the
> same report.
>
> Are you saying that it is necessary to insert the formula manually for it to
> be recorded by a macro, and that I can not copy the formula from another
> worksheet?
>
> Sarah
>
> "Mike H" wrote:
>
> > Sarah,
> >
> > You can record formula entry with the macro recorder:-
> > ActiveCell.Formula = "=SUM(A3:A9)"
> > ActiveCell.FormulaR1C1 = "=SUM(RC[-1]:R[6]C[-1])"
> >
> > These 2 formula are the same, they are in B3 and add up A3 to A9. The first
> > is entered manually and the second is the recorded version of the same thing.
> >
> > What precisely are you trying to do?
> >
> >
> > Mike
> >
> >
> > "Sarah" wrote:
> >
> > > I tried recording some formulas into a macro, but this doesn't work. Is it
> > > possible to do so, without using Visual Basic programming? Can it be done
> > > using Visual Basic programming - I am not an expert :-)

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macros and Formulas alexaed Microsoft Excel Programming 2 4th Oct 2007 06:52 PM
Macro to insert copy and insert formulas only to next blank row bob Microsoft Excel Programming 0 30th Jun 2006 12:02 PM
Macros within formulas praveen_khm Microsoft Excel Programming 3 16th Jan 2006 02:18 PM
formulas to macros =?Utf-8?B?cmFqYQ==?= Microsoft Excel Programming 0 21st Sep 2005 02:01 PM
Formulas in macros shimeel Microsoft Excel Misc 1 1st Nov 2004 06:14 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:45 PM.