Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Insert a formula into a cell

I want to use VBA to inert a formula into a cell.

I want to get the contents of Cell B7 on the "Balance Sheet" and insert that
into cell B$ on the current sheet.
Here is what I have but it's not working:
Range("B4").Select
ActiveCell.FormulaR1C1 = "='Balance Sheet'!B7"

When I do that I get a #NAME? error.

Help please!

And... thanks!

Jon


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Insert a formula into a cell

since your formula is written in A1 style referencing, why would you use
formulaR1C1 telling excel it is in R1C1 style?

ActiveCell.Formula = "='Balance Sheet'!B7"

should work.

--
Regards,
Tom Ogilvy


"jonco" wrote:

I want to use VBA to inert a formula into a cell.

I want to get the contents of Cell B7 on the "Balance Sheet" and insert that
into cell B$ on the current sheet.
Here is what I have but it's not working:
Range("B4").Select
ActiveCell.FormulaR1C1 = "='Balance Sheet'!B7"

When I do that I get a #NAME? error.

Help please!

And... thanks!

Jon



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 367
Default Insert a formula into a cell

The problem is you are trying to use A1 style referencing, rather than R1C1
style. You can change your code to work as:

Range("B4").Select
ActiveCell.FormulaR1C1 = "='Balance Sheet'!R7C2"

Or, you can simply use:

Range("B4") = Sheets("Balance Sheet").Range("B7")

The above will not enter a formula, so if you do in fact need a formula, you
can use the R1C1 style as:

Range("B4").FormulaR1C1 = "='Balance Sheet'!R7C2"

Jason

"jonco" wrote:

I want to use VBA to inert a formula into a cell.

I want to get the contents of Cell B7 on the "Balance Sheet" and insert that
into cell B$ on the current sheet.
Here is what I have but it's not working:
Range("B4").Select
ActiveCell.FormulaR1C1 = "='Balance Sheet'!B7"

When I do that I get a #NAME? error.

Help please!

And... thanks!

Jon



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Insert a formula into a cell

I used that (R1C1) because I found it somewhere else and it seemed to work
for that particular application.
Still struggling with the syntax. But your ideas both worked.

I DO appreciate the help!

Thanks

"jonco" wrote in message
. net...
I want to use VBA to inert a formula into a cell.

I want to get the contents of Cell B7 on the "Balance Sheet" and insert
that into cell B$ on the current sheet.
Here is what I have but it's not working:
Range("B4").Select
ActiveCell.FormulaR1C1 = "='Balance Sheet'!B7"

When I do that I get a #NAME? error.

Help please!

And... thanks!

Jon



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
Find a cell and then insert a formula into adjacent cell crowdx42[_8_] Excel Programming 7 August 21st 06 02:53 PM
Insert Formula in Cell with VBA Ctech[_137_] Excel Programming 1 April 5th 06 11:27 AM
Using VBA to Insert a formula in a cell Lee Excel Programming 2 March 17th 06 01:23 AM
Insert value of formula into cell Bill Excel Programming 16 August 1st 05 06:16 PM
insert formula in last cell J_Gold Excel Programming 6 May 31st 05 03:14 AM


All times are GMT +1. The time now is 09:54 AM.

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"