Selection Formula=FormulaLocal

alfredo sanchez

New Member
Joined
Apr 3, 2003
Messages
42
Hi!
Hope some of you guys can help me with this one:
I'm modifying references in formulas via vba, but when the macro writes back the cells' value, I get #NAME? error. So I'm trying to write back the formula as FormulaLocal in order to my XL version be able to work with it.
This are the lines of code I'm using
Code:
  For i = 1 To c_formls
    If Selection.Cells(i).HasFormula Then
          Selection.Cells(i).Formula = Application.ConvertFormula _
          (Formula:=Selection.Cells(i).Formula, FromReferenceStyle:=xlA1, _
          ToReferenceStyle:=xlA1, ToAbsolute:=xlAbsolute)
    End If
    Next i

c_formls has the number of cells in ActiveSheet that have formula in them

Can you help me to put the FormulaLocal entry in the right place?

Thank you in advance.
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
thank you COLO for the link, great site and utilities, but - there's always a but -, how can I provide my macro with that function?.
I'll explain: I'm using XL 2k2XP spanish version with VBE to edit my code, the problem is that VBA is NOT spanish version, i.e. if you want excel to OFFSET(1,0), you have to write OFFSET and not DESREF which is the spanish command. The same apply for built-in Functions, so when I try to change relative to absolute references via VBA, it returns the english version that the spreadsheet doesn't recognize.
Hope you can help me.

This is the line of code I'm using:

Code:
Selection.Cells(i).Formula = Application.ConvertFormula _
          (Formula:=Selection.Cells(i).Formula, FromReferenceStyle:=xlA1, _
          ToReferenceStyle:=xlA1, ToAbsolute:=xlAbsolute)
 
Upvote 0
What does this return ?

Code:
MsgBox Application.ConvertFormula _ 
          (Formula:=Selection.Cells(i).Formula, FromReferenceStyle:=xlA1, _ 
          ToReferenceStyle:=xlA1, ToAbsolute:=xlAbsolute)
 
Upvote 0
Hi Juan Pablo.

I'm using cell B24 which have formula: =SUMA(B22:R22), the task I'm trying is to get =SUMA($B$22:$R$22), but applying the line of code I get:
SUM(B22:R22) which in-screen shows #NOMBRE?
 
Upvote 0
there is no messagebox, code stops with "No coinciden los tipos"




Podremos pasar este topico a la seccion de español, para explicar mejor?
 
Upvote 0

Forum statistics

Threads
1,223,934
Messages
6,175,488
Members
452,648
Latest member
Candace H

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top