Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Applying formulae to cells???


Is it possible to create a macro that when a selection of cells is
picked and the macro run a box will appear on the screen which allows
the user to enter a formula which is then applied to all the cells
selected and the new value returned in the original cells?

ie i highlight cells a1, a2, a3... click the macro. A box appears
prompting me to enter a formula of my choosing to apply to the
selection. On clicking OK the formula is applied and the new values
returned to a1, a2, a3

Apologies if this is really simple!!! And thanks in advance for any
help


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Applying formulae to cells???

Try something like the following:

Sub AAA()
Dim F As String
Dim Rng As Range
F = InputBox("Enter A Formula")
If F < "" Then
For Each Rng In Selection.Cells
Rng.Formula = F
Next Rng
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"index" wrote in message
...

Is it possible to create a macro that when a selection of cells

is
picked and the macro run a box will appear on the screen which

allows
the user to enter a formula which is then applied to all the

cells
selected and the new value returned in the original cells?

ie i highlight cells a1, a2, a3... click the macro. A box

appears
prompting me to enter a formula of my choosing to apply to the
selection. On clicking OK the formula is applied and the new

values
returned to a1, a2, a3

Apologies if this is really simple!!! And thanks in advance for

any
help


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from

http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by step guide

to creating financial statements


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Applying formulae to cells???

Index,

Here's one way. It first prompts for the user to select the range to apply
the formula to, then for the formula. There is no validation on the formula

Sub ApplyFormulae()
Dim rng As Range
Dim sFormula As String

On Error Resume Next
Set rng = Application.InputBox("Please select range to apply formula
to", , , , , , , 8)
On Error GoTo 0
If rng Is Nothing Then
MsgBox "OK, try again later"
Exit Sub
Else
sFormula = InputBox("Please input formula (with leading =)")
If sFormula = "" Then
MsgBox "It's your choice"
Exit Sub
Else
rng.Formula = sFormula
End If
End If

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"index" wrote in message
...

Is it possible to create a macro that when a selection of cells is
picked and the macro run a box will appear on the screen which allows
the user to enter a formula which is then applied to all the cells
selected and the new value returned in the original cells?

ie i highlight cells a1, a2, a3... click the macro. A box appears
prompting me to enter a formula of my choosing to apply to the
selection. On clicking OK the formula is applied and the new values
returned to a1, a2, a3

Apologies if this is really simple!!! And thanks in advance for any
help


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by step guide to

creating financial statements


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Applying formulae to cells???

Chip and Bob both read you query as wanting the formula put into the
selected cells. I read it differently. Am I the one out of step? It
wouldn't be the first time.
I think that you don't want a formula placed in those cells. Instead,
you want the current cell contents to be one of the arguments of the formula
and then you want the result of the formula put into the same cell. For
instance, if the cell contains 5 and the formula you input is
(CurrentValue*A1) then you would get the result of 5*A1 put into that cell,
not a formula. Is that what you want? HTH Otto
"index" wrote in message
...

Is it possible to create a macro that when a selection of cells is
picked and the macro run a box will appear on the screen which allows
the user to enter a formula which is then applied to all the cells
selected and the new value returned in the original cells?

ie i highlight cells a1, a2, a3... click the macro. A box appears
prompting me to enter a formula of my choosing to apply to the
selection. On clicking OK the formula is applied and the new values
returned to a1, a2, a3

Apologies if this is really simple!!! And thanks in advance for any
help


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by step guide to

creating financial statements


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Applying formulae to cells???

You can do this without a macro if you wished.

Select your cells A1:A3. Type a formula in active cell then hit CRTL + ENTER

Gord Dibben XL2002

On Sat, 6 Dec 2003 10:59:32 -0600, index
wrote:


Is it possible to create a macro that when a selection of cells is
picked and the macro run a box will appear on the screen which allows
the user to enter a formula which is then applied to all the cells
selected and the new value returned in the original cells?

ie i highlight cells a1, a2, a3... click the macro. A box appears
prompting me to enter a formula of my choosing to apply to the
selection. On clicking OK the formula is applied and the new values
returned to a1, a2, a3

Apologies if this is really simple!!! And thanks in advance for any
help


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements


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
Applying Formulae to a worksheet which are hidden Ra New Users to Excel 11 May 23rd 09 07:16 PM
Applying a formula to multiple cells Lindsay Excel Discussion (Misc queries) 2 April 2nd 09 10:34 PM
Applying change to selected cells Colin Hayes Excel Worksheet Functions 4 February 13th 09 09:11 PM
Applying format to cells merry_fay Excel Discussion (Misc queries) 2 October 31st 07 12:49 PM
Applying Formulas to Visible Cells Only SteveC Excel Discussion (Misc queries) 7 June 26th 06 11:44 PM


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