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


Excel 2003 VBA
Hi all,
I am attempting to write a macro to insert a formula into a specific cell.
I already have the formula written and working in a normal spreadsheet. I am
just trying to insert it exactly how it is in the same cell of several other
workbooks.

In order to get the syntax correct I tried recording a macro and "cut &
pasting" the formula. Normally this generate the VBA code with the right
syntax to use. However, for this particular formula I am getting an "Unable
to Record" error message. Is there something in the formula that is causing
a problem?? Thanks.

'48 Formula as taken from workbook
'=sum(INDEX(B11:F20,MATCH("Emerging Markets-Investment
Grade",B11:B20,0),MATCH("Net Market Weight
(%)",B11:F11,0)),INDEX(B11:F20,MATCH("Emerging Markets-High
Yield",B11:B20,0),MATCH("Net Market Weight (%)",B11:F11,0)))

Range("D4").Select
'Range("D5").FormulaR1C1 = _
"=SUM(INDEX(B11:F20,MATCH(""Emerging Markets-Investment
Grade"",B11:B20,0),MATCH(""Net Market Weight
(%)"",B11:F11,0)),INDEX(B11:F20,MATCH(""Emerging Markets-High
Yield"",B11:B20,0),MATCH(""Net Market Weight (%)"",B11:F11,0)))"



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default Recording Macro - Insert Formula


This may be the problem:

http://support.microsoft.com/kb/212172

HTH,

Eric
---------------------
If toast always lands butter-side down, and cats always land on their feet,
what happen if you strap toast on the back of a cat and drop it?
Steven Wright (1955 - )


"Bythsx-Addagio" wrote:

Excel 2003 VBA
Hi all,
I am attempting to write a macro to insert a formula into a specific cell.
I already have the formula written and working in a normal spreadsheet. I am
just trying to insert it exactly how it is in the same cell of several other
workbooks.

In order to get the syntax correct I tried recording a macro and "cut &
pasting" the formula. Normally this generate the VBA code with the right
syntax to use. However, for this particular formula I am getting an "Unable
to Record" error message. Is there something in the formula that is causing
a problem?? Thanks.

'48 Formula as taken from workbook
'=sum(INDEX(B11:F20,MATCH("Emerging Markets-Investment
Grade",B11:B20,0),MATCH("Net Market Weight
(%)",B11:F11,0)),INDEX(B11:F20,MATCH("Emerging Markets-High
Yield",B11:B20,0),MATCH("Net Market Weight (%)",B11:F11,0)))

Range("D4").Select
'Range("D5").FormulaR1C1 = _
"=SUM(INDEX(B11:F20,MATCH(""Emerging Markets-Investment
Grade"",B11:B20,0),MATCH(""Net Market Weight
(%)"",B11:F11,0)),INDEX(B11:F20,MATCH(""Emerging Markets-High
Yield"",B11:B20,0),MATCH(""Net Market Weight (%)"",B11:F11,0)))"



  #3   Report Post  
Posted to microsoft.public.excel.programming
jaf jaf is offline
external usenet poster
 
Posts: 300
Default Recording Macro - Insert Formula


Hi,
Range("D4").Select
Range("D5").FormulaR1C1 = _
"=SUM(INDEX(B11:F20,MATCH(""Emerging Markets-Investment
Grade"",B11:B20,0),MATCH(""Net Market Weight
(%)"",B11:F11,0)),INDEX(B11:F20,MATCH(""Emerging Markets-High
Yield"",B11:B20,0),MATCH(""Net Market Weight (%)"",B11:F11,0)))"

I deleted the single quote and this code ran fine.

FYI: You're selecting D4 and pasting into D5. Don't know if that's what you want.

John


"Bythsx-Addagio" wrote in message
...
Excel 2003 VBA
Hi all,
I am attempting to write a macro to insert a formula into a specific cell.
I already have the formula written and working in a normal spreadsheet. I am
just trying to insert it exactly how it is in the same cell of several other
workbooks.

In order to get the syntax correct I tried recording a macro and "cut &
pasting" the formula. Normally this generate the VBA code with the right
syntax to use. However, for this particular formula I am getting an "Unable
to Record" error message. Is there something in the formula that is causing
a problem?? Thanks.

'48 Formula as taken from workbook
'=sum(INDEX(B11:F20,MATCH("Emerging Markets-Investment
Grade",B11:B20,0),MATCH("Net Market Weight
(%)",B11:F11,0)),INDEX(B11:F20,MATCH("Emerging Markets-High
Yield",B11:B20,0),MATCH("Net Market Weight (%)",B11:F11,0)))

Range("D4").Select
'Range("D5").FormulaR1C1 = _
"=SUM(INDEX(B11:F20,MATCH(""Emerging Markets-Investment
Grade"",B11:B20,0),MATCH(""Net Market Weight
(%)"",B11:F11,0)),INDEX(B11:F20,MATCH(""Emerging Markets-High
Yield"",B11:B20,0),MATCH(""Net Market Weight (%)"",B11:F11,0)))"




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
recording macro for a formula timmulla Excel Programming 3 November 26th 07 04:11 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 1 February 5th 07 09:31 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 3 February 5th 07 08:22 PM
HOW DO YOU INSERT A MACRO INTO A FORMULA blopreste3180 Excel Worksheet Functions 6 December 21st 05 08:41 PM
recording macro to paste a copied ws formula Peter[_21_] Excel Programming 2 December 11th 04 09:36 PM


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