Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 333
Default Insert Formula

Hi

I've been trying to get this to work. I want to programmatically insert
this formula into a cell in the active worksheet. I want to link the two
cells which are in the same workbook.

='Main Sheet'!$E$9

I've tried various ways with no luck. I just don't seem to get this.

Here's my latest try.

With ActiveSheet
..Range("G9").Formula = "'=Main Sheet'!$E$9"
End With

The formula is there but as a string.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Insert Formula

Hi Karen,

Try this:-

With ActiveSheet
.Range("G9").FormulaR1C1 = "='Main Sheet'!RC[-2]"
End With

As an added lesson, try recording the macro to obtain the syntax when you
are having problems. It would have recorded like this:-

Range("G9").Select
ActiveCell.FormulaR1C1 = "='Main Sheet'!RC[-2]"

then you can edit it to get the above.

Regards,

OssieMac




"Karen53" wrote:

Hi

I've been trying to get this to work. I want to programmatically insert
this formula into a cell in the active worksheet. I want to link the two
cells which are in the same workbook.

='Main Sheet'!$E$9

I've tried various ways with no luck. I just don't seem to get this.

Here's my latest try.

With ActiveSheet
.Range("G9").Formula = "'=Main Sheet'!$E$9"
End With

The formula is there but as a string.

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Insert Formula

Just another little snippet. If you recorded the macro so that the link
address is absolute (that is press F4 immediately after selecting the the
linked cell) then it would look like this:-

ActiveCell.FormulaR1C1 = "='Main Sheet'!R9C5"

You will see that although VBA uses Row Column for the cell address, when
you view the formula on the work sheet it is ='Main Sheet'!$E$9

regards,

OssieMac

"OssieMac" wrote:

Hi Karen,

Try this:-

With ActiveSheet
.Range("G9").FormulaR1C1 = "='Main Sheet'!RC[-2]"
End With

As an added lesson, try recording the macro to obtain the syntax when you
are having problems. It would have recorded like this:-

Range("G9").Select
ActiveCell.FormulaR1C1 = "='Main Sheet'!RC[-2]"

then you can edit it to get the above.

Regards,

OssieMac




"Karen53" wrote:

Hi

I've been trying to get this to work. I want to programmatically insert
this formula into a cell in the active worksheet. I want to link the two
cells which are in the same workbook.

='Main Sheet'!$E$9

I've tried various ways with no luck. I just don't seem to get this.

Here's my latest try.

With ActiveSheet
.Range("G9").Formula = "'=Main Sheet'!$E$9"
End With

The formula is there but as a string.

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 333
Default Insert Formula

Thank you OssieMac!

After so much frustration it's heartening to see I was so close to the
correct answer!

Karen

"OssieMac" wrote:

Just another little snippet. If you recorded the macro so that the link
address is absolute (that is press F4 immediately after selecting the the
linked cell) then it would look like this:-

ActiveCell.FormulaR1C1 = "='Main Sheet'!R9C5"

You will see that although VBA uses Row Column for the cell address, when
you view the formula on the work sheet it is ='Main Sheet'!$E$9

regards,

OssieMac

"OssieMac" wrote:

Hi Karen,

Try this:-

With ActiveSheet
.Range("G9").FormulaR1C1 = "='Main Sheet'!RC[-2]"
End With

As an added lesson, try recording the macro to obtain the syntax when you
are having problems. It would have recorded like this:-

Range("G9").Select
ActiveCell.FormulaR1C1 = "='Main Sheet'!RC[-2]"

then you can edit it to get the above.

Regards,

OssieMac




"Karen53" wrote:

Hi

I've been trying to get this to work. I want to programmatically insert
this formula into a cell in the active worksheet. I want to link the two
cells which are in the same workbook.

='Main Sheet'!$E$9

I've tried various ways with no luck. I just don't seem to get this.

Here's my latest try.

With ActiveSheet
.Range("G9").Formula = "'=Main Sheet'!$E$9"
End With

The formula is there but as a string.

Thanks

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
insert formula [email protected] Excel Programming 3 May 17th 06 11:06 PM
trying to insert a formula davegb Excel Programming 3 April 25th 06 08:45 PM
How to insert = in formula bar Tirtha Raj Adhikari Excel Discussion (Misc queries) 1 September 14th 05 09:02 AM
insert a new row by formula Doug Excel Worksheet Functions 3 November 18th 04 12:28 PM
Insert Formula Kevin Excel Programming 4 September 10th 04 04:56 PM


All times are GMT +1. The time now is 03:40 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"