Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Help with renaming in Visual Basic

I have recorded a macro to do mathmatical calculations. When I go into
Visual Basic, the recorder has put it's own language where my cell reference
would be. See example below:


"=IF(R[-4]C[-1]=0,0,SUMIF(R[-7]C[-30]:R[65491]C[-30],RC[-3],R[-7]C[-17]:R[65491]C[-17])/R[-4]C[-1])"

I want to change it to reference the actual cells, but when I change for
example the R[-4]C[-1]=0 to AC4-0, the macro will not return any values,
just gives me a #NAME? error message. What am I missing here?

Thanks..
Laurie
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Help with renaming in Visual Basic

The macro recorder recorded your formula in R1C1 reference style.

You can see this if you use this (in xl2003 menus):
Tools|Options|General tab|check r1c1 reference style

The column letters will become numbers.

You may like how this works.

R5C3 is the same as $C$5
R[5]C[3] is 5 rows down from the current row and 3 columns to the right of the
current column.

This works very nicely if your formula always referred to cells on the same row.
=rc[3]+rc[-2]
would add the cell 2 columns to the left with the cell three columns to the
right.

To make your R1C1 formula work in your code, you may be able to just use:

SomeCell.formulaR1C1 = "=IF(R[-4]C[-1]=0,0,SUM.....

Instead of using the .formula property.




Alberta Rose wrote:

I have recorded a macro to do mathmatical calculations. When I go into
Visual Basic, the recorder has put it's own language where my cell reference
would be. See example below:


"=IF(R[-4]C[-1]=0,0,SUMIF(R[-7]C[-30]:R[65491]C[-30],RC[-3],R[-7]C[-17]:R[65491]C[-17])/R[-4]C[-1])"

I want to change it to reference the actual cells, but when I change for
example the R[-4]C[-1]=0 to AC4-0, the macro will not return any values,
just gives me a #NAME? error message. What am I missing here?

Thanks..
Laurie


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Help with renaming in Visual Basic

It's using RC notation. For example,

R[-4]C[-1] is 4 rows up and 1 column to the left of the current cell. I'm
not sure there is any way around using this in VBA.

HTH,
Barb Reinhardt

"Alberta Rose" wrote:

I have recorded a macro to do mathmatical calculations. When I go into
Visual Basic, the recorder has put it's own language where my cell reference
would be. See example below:


"=IF(R[-4]C[-1]=0,0,SUMIF(R[-7]C[-30]:R[65491]C[-30],RC[-3],R[-7]C[-17]:R[65491]C[-17])/R[-4]C[-1])"

I want to change it to reference the actual cells, but when I change for
example the R[-4]C[-1]=0 to AC4-0, the macro will not return any values,
just gives me a #NAME? error message. What am I missing here?

Thanks..
Laurie

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
Is Visual Basic the same as Visual Studio 2008? Mike Stewart Excel Worksheet Functions 5 January 11th 09 04:58 PM
Programmatic access to visual basic project via Visual FoxPro Jim Rech Excel Programming 0 January 11th 07 01:53 PM
Make visual basic truely visual! GraphicalGuy Excel Programming 0 October 20th 06 05:53 PM
Can I run Visual Basic procedure using Excel Visual Basic editor? john.jacobs71[_2_] Excel Programming 3 December 26th 05 02:22 PM
changing the visual basic in office 2003 to visual studio net bigdaddy3 Excel Discussion (Misc queries) 1 September 13th 05 10:57 AM


All times are GMT +1. The time now is 10:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"