PC Review


Reply
Thread Tools Rate Thread

Changing text to formula in a range of cells

 
 
Bob Arnett
Guest
Posts: n/a
 
      6th Jul 2008
I'm new in Excel having recently moved from another spreadsheet brand that
didn't require the "=" preceding a formula so I'm constantly running into the
problem of having to go back and insert the "=" in each formula cell. To do
this, I came up with:

Sub Equation()

With Selection
.FormulaR1C1 = "=" & .FormulaR1C1
End With

End Sub

.... which works perfectly as long as only one cell is selected. If I select
a range of cells I get the error message:

Run-time error '13':
Type mismatch

What to do?
 
Reply With Quote
 
 
 
 
Tim Zych
Guest
Posts: n/a
 
      6th Jul 2008
How about looping.

Dim rng As Range, cell As Range
Set rng = Selection
For Each cell In rng.Cells
cell.FormulaR1C1 = "=" & cell.Value
Next

--
Tim Zych
www.higherdata.com
Compare data in worksheets and find differences with Workbook Compare
A free, powerful, flexible Excel utility


"Bob Arnett" <(E-Mail Removed)> wrote in message
news:0438F1F2-1328-4DE0-86BD-(E-Mail Removed)...
> I'm new in Excel having recently moved from another spreadsheet brand that
> didn't require the "=" preceding a formula so I'm constantly running into
> the
> problem of having to go back and insert the "=" in each formula cell. To
> do
> this, I came up with:
>
> Sub Equation()
>
> With Selection
> .FormulaR1C1 = "=" & .FormulaR1C1
> End With
>
> End Sub
>
> ... which works perfectly as long as only one cell is selected. If I
> select
> a range of cells I get the error message:
>
> Run-time error '13':
> Type mismatch
>
> What to do?



 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      6th Jul 2008
You will want to iterate through the cells in the Selection...

Dim R As Range
For Each R In Selection
R.FormulaR1C1 = "=" & R.FormulaR1C1
Next

Rick


"Tim Zych" <tzych@NOSp@mE@RTHLINKDOTNET> wrote in message
news:(E-Mail Removed)...
> How about looping.
>
> Dim rng As Range, cell As Range
> Set rng = Selection
> For Each cell In rng.Cells
> cell.FormulaR1C1 = "=" & cell.Value
> Next
>
> --
> Tim Zych
> www.higherdata.com
> Compare data in worksheets and find differences with Workbook Compare
> A free, powerful, flexible Excel utility
>
>
> "Bob Arnett" <(E-Mail Removed)> wrote in message
> news:0438F1F2-1328-4DE0-86BD-(E-Mail Removed)...
>> I'm new in Excel having recently moved from another spreadsheet brand
>> that
>> didn't require the "=" preceding a formula so I'm constantly running into
>> the
>> problem of having to go back and insert the "=" in each formula cell. To
>> do
>> this, I came up with:
>>
>> Sub Equation()
>>
>> With Selection
>> .FormulaR1C1 = "=" & .FormulaR1C1
>> End With
>>
>> End Sub
>>
>> ... which works perfectly as long as only one cell is selected. If I
>> select
>> a range of cells I get the error message:
>>
>> Run-time error '13':
>> Type mismatch
>>
>> What to do?

>
>


 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      6th Jul 2008
Sorry... I accidentally sent this post when I actually meant to cancel it.

Rick


"Rick Rothstein (MVP - VB)" <(E-Mail Removed)> wrote in
message news:(E-Mail Removed)...
> You will want to iterate through the cells in the Selection...
>
> Dim R As Range
> For Each R In Selection
> R.FormulaR1C1 = "=" & R.FormulaR1C1
> Next
>
> Rick
>
>
> "Tim Zych" <tzych@NOSp@mE@RTHLINKDOTNET> wrote in message
> news:(E-Mail Removed)...
>> How about looping.
>>
>> Dim rng As Range, cell As Range
>> Set rng = Selection
>> For Each cell In rng.Cells
>> cell.FormulaR1C1 = "=" & cell.Value
>> Next
>>
>> --
>> Tim Zych
>> www.higherdata.com
>> Compare data in worksheets and find differences with Workbook Compare
>> A free, powerful, flexible Excel utility
>>
>>
>> "Bob Arnett" <(E-Mail Removed)> wrote in message
>> news:0438F1F2-1328-4DE0-86BD-(E-Mail Removed)...
>>> I'm new in Excel having recently moved from another spreadsheet brand
>>> that
>>> didn't require the "=" preceding a formula so I'm constantly running
>>> into the
>>> problem of having to go back and insert the "=" in each formula cell. To
>>> do
>>> this, I came up with:
>>>
>>> Sub Equation()
>>>
>>> With Selection
>>> .FormulaR1C1 = "=" & .FormulaR1C1
>>> End With
>>>
>>> End Sub
>>>
>>> ... which works perfectly as long as only one cell is selected. If I
>>> select
>>> a range of cells I get the error message:
>>>
>>> Run-time error '13':
>>> Type mismatch
>>>
>>> What to do?

>>
>>

>


 
Reply With Quote
 
Bob Arnett
Guest
Posts: n/a
 
      7th Jul 2008
Cool! Worked perfectly. I'll get the hang of this yet.

"Tim Zych" wrote:

> How about looping.
>
> Dim rng As Range, cell As Range
> Set rng = Selection
> For Each cell In rng.Cells
> cell.FormulaR1C1 = "=" & cell.Value
> Next
>
> --
> Tim Zych
> www.higherdata.com
> Compare data in worksheets and find differences with Workbook Compare
> A free, powerful, flexible Excel utility
>
>
> "Bob Arnett" <(E-Mail Removed)> wrote in message
> news:0438F1F2-1328-4DE0-86BD-(E-Mail Removed)...
> > I'm new in Excel having recently moved from another spreadsheet brand that
> > didn't require the "=" preceding a formula so I'm constantly running into
> > the
> > problem of having to go back and insert the "=" in each formula cell. To
> > do
> > this, I came up with:
> >
> > Sub Equation()
> >
> > With Selection
> > .FormulaR1C1 = "=" & .FormulaR1C1
> > End With
> >
> > End Sub
> >
> > ... which works perfectly as long as only one cell is selected. If I
> > select
> > a range of cells I get the error message:
> >
> > Run-time error '13':
> > Type mismatch
> >
> > What to do?

>
>
>

 
Reply With Quote
 
 
 
Reply

« e-mail | matching »
Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Copy formula into multiple cells without changing range MartinW Microsoft Excel Worksheet Functions 0 10th Dec 2006 03:12 AM
Re: Copy formula into multiple cells without changing range Peo Sjoblom Microsoft Excel Worksheet Functions 0 9th Dec 2006 11:48 PM
Pasting a formula in multiple cells without changing the range =?Utf-8?B?SmVmZiBXaGVlbGVy?= Microsoft Excel Misc 3 15th Jun 2006 04:52 PM
is there a formula that can count a range of cells with text? Yehudit Microsoft Excel Worksheet Functions 1 11th Mar 2004 08:04 PM
Changing formula in multiple cells or range simultaneously Michael Microsoft Excel Misc 2 1st Sep 2003 07:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:50 AM.