Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Converting a Formula stored as String to real Formula

Hi,

I have a MS Access DB that export an excel sheet and in one of the
columns it has a formula stored as string with the little " ' " in
front of the " = " sign.

To convert it manually I select the range and run the text to columns.
But when I try it in a macro it doesn't work.

I have tried a code that looks like this:

For Each c In Range("J2:K5")
c.Formula = c.Value
Next c

or even

For Each c In Range("J2:K5")
c.Formula = Right(c.Value, -1 + Len(c.Value))
Next c


being that the value of the cell is printed in the debug as:
=SE(ÉNÚM(LOCALIZAR("#";BLP("c Equity";"ID_SEDOL1")));"";BLP("c
Equity";"ID_SEDOL1"))

when I select the same cell on excel I see:
'=SE(ÉNÚM(LOCALIZAR("#";BLP("c Equity";"ID_SEDOL1")));"";BLP("c
Equity";"ID_SEDOL1"))

in the first case I keep with the same formula stored as string.
In the second case I crop part of my formula, but it keeps it as
string.


Does any one have a clue on how to work around.

thank you,
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default Converting a Formula stored as String to real Formula

Hi,

Change the range to suit and try this

Sub changetoformula()
Set myrange = Range("A1:a100")
For Each c In myrange
If c.HasFormula = False Then
c.Formula = c.Value
End If
Next
End Sub

Mike

"BlueD" wrote:

Hi,

I have a MS Access DB that export an excel sheet and in one of the
columns it has a formula stored as string with the little " ' " in
front of the " = " sign.

To convert it manually I select the range and run the text to columns.
But when I try it in a macro it doesn't work.

I have tried a code that looks like this:

For Each c In Range("J2:K5")
c.Formula = c.Value
Next c

or even

For Each c In Range("J2:K5")
c.Formula = Right(c.Value, -1 + Len(c.Value))
Next c


being that the value of the cell is printed in the debug as:
=SE(ÉNÚM(LOCALIZAR("#";BLP("c Equity";"ID_SEDOL1")));"";BLP("c
Equity";"ID_SEDOL1"))

when I select the same cell on excel I see:
'=SE(ÉNÚM(LOCALIZAR("#";BLP("c Equity";"ID_SEDOL1")));"";BLP("c
Equity";"ID_SEDOL1"))

in the first case I keep with the same formula stored as string.
In the second case I crop part of my formula, but it keeps it as
string.


Does any one have a clue on how to work around.

thank you,

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Converting a Formula stored as String to real Formula

Sub Change()
For Each c In Range("J5:K17")
c.NumberFormat = "General"
c.Formula = c.Value
Next c
End Sub


Gord Dibben MS Excel MVP

On Mon, 14 Jan 2008 04:18:36 -0800 (PST), BlueD wrote:

Hi,

I have a MS Access DB that export an excel sheet and in one of the
columns it has a formula stored as string with the little " ' " in
front of the " = " sign.

To convert it manually I select the range and run the text to columns.
But when I try it in a macro it doesn't work.

I have tried a code that looks like this:

For Each c In Range("J2:K5")
c.Formula = c.Value
Next c

or even

For Each c In Range("J2:K5")
c.Formula = Right(c.Value, -1 + Len(c.Value))
Next c


being that the value of the cell is printed in the debug as:
=SE(ÉNÚM(LOCALIZAR("#";BLP("c Equity";"ID_SEDOL1")));"";BLP("c
Equity";"ID_SEDOL1"))

when I select the same cell on excel I see:
'=SE(ÉNÚM(LOCALIZAR("#";BLP("c Equity";"ID_SEDOL1")));"";BLP("c
Equity";"ID_SEDOL1"))

in the first case I keep with the same formula stored as string.
In the second case I crop part of my formula, but it keeps it as
string.


Does any one have a clue on how to work around.

thank you,


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 897
Default Converting a Formula stored as String to real Formula

How about

Sub fixformulas()

Dim cell As Excel.Range
For Each cell In Selection
cell = "=" & Right(cell, Len(cell) - 1)
Next cell

End Sub

Highlight the offending data and run. Crude but effective.

HTH,
JP

On Jan 14, 7:18*am, BlueD wrote:
Hi,

I have a MS Access DB that export an excel sheet and in one of the
columns it has a formula stored as string with the little " ' " in
front of the " = " sign.

To convert it manually I select the range and run the text to columns.
But when I try it in a macro it doesn't work.

I have tried a code that looks like this:

For Each c In Range("J2:K5")
* c.Formula = c.Value
Next c

or even

For Each c In Range("J2:K5")
* c.Formula = Right(c.Value, -1 + Len(c.Value))
Next c

being that the value of the cell is printed in the debug as:
=SE(ÉNÚM(LOCALIZAR("#";BLP("c Equity";"ID_SEDOL1")));"";BLP("c
Equity";"ID_SEDOL1"))

when I select the same cell on excel I see:
'=SE(ÉNÚM(LOCALIZAR("#";BLP("c Equity";"ID_SEDOL1")));"";BLP("c
Equity";"ID_SEDOL1"))

in the first case I keep with the same formula stored as string.
In the second case I crop part of my formula, but it keeps it as
string.

Does any one have a clue on how to work around.

thank you,


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
Need help converting Number stored as Text to Date LuvHaleiwa Excel Discussion (Misc queries) 4 December 21st 07 08:09 PM
Using value stored in cell in formula Philip Gabe Excel Worksheet Functions 1 March 30th 07 09:55 PM
Converting text string back into a formula Kevin c Excel Discussion (Misc queries) 1 October 17th 06 09:52 PM
Converting numbers stored as dates to text in Excel David from Furdale Excel Discussion (Misc queries) 1 July 17th 06 06:34 PM
"real" formula Jiri Cihar Excel Discussion (Misc queries) 1 February 22nd 05 04:27 PM


All times are GMT +1. The time now is 01:55 PM.

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"