Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default Rebuild Array-formulas

Hi There,

Array-formulas are incredibly useful ... although most people are
impressed with the power of it, they have serious difficulties to
understand that they need to rebuild them with CTRL+SHIFT+Enter.

Therefo

I would like to rebuild to be able to rebuild my Array-formulas
automatically. It jams though ..

Sub Rebuild_ArrayFormula()
Dim cells As Long, i As Long
Dim rngcel As Range

cells = Selection.Cells.Count
i = 1
For Each rngcel In Selection
rngcel.FormulaArray = rngcel.Formula '<====jams up here ...
Next
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Rebuild Array-formulas

This code, which is virtually identical you yours, ran for me:

Dim Cell As Range
For Each Cell In Selection
Cell.FormulaArray = Cell.Formula
Next


--
Jim
"Sige" wrote in message
oups.com...
| Hi There,
|
| Array-formulas are incredibly useful ... although most people are
| impressed with the power of it, they have serious difficulties to
| understand that they need to rebuild them with CTRL+SHIFT+Enter.
|
| Therefo
|
| I would like to rebuild to be able to rebuild my Array-formulas
| automatically. It jams though ..
|
| Sub Rebuild_ArrayFormula()
| Dim cells As Long, i As Long
| Dim rngcel As Range
|
| cells = Selection.Cells.Count
| i = 1
| For Each rngcel In Selection
| rngcel.FormulaArray = rngcel.Formula '<====jams up here ...
| Next
| End Sub
|


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default Rebuild Array-formulas

Hi Jim,

Thanks! Glad to hear that it works for you! At least I am going in the
right direction.
But would it surprise you if I say it jams now on?:

Cell.FormulaArray = Cell.Formula

;o)

I have no idea why it jams... (XL97-SR2)
Sige

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Rebuild Array-formulas

If you have a multicell array formula, then it would cause problems if you
try to change a single cell in the array.

if it is a single cell array formula as tested by Jim, then, as he has
shown, it will work.

--
Regards,
Tom Ogilvy

"Sige" wrote in message
oups.com...
Hi Jim,

Thanks! Glad to hear that it works for you! At least I am going in the
right direction.
But would it surprise you if I say it jams now on?:

Cell.FormulaArray = Cell.Formula

;o)

I have no idea why it jams... (XL97-SR2)
Sige



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Rebuild Array-formulas

Tom raises a good point. If you're array entering a single (identical)
formula in a range I think you can forget the loop and just do:

Select.FormulaArray = ActiveCell.Formula

--
Jim
"Sige" wrote in message
oups.com...
| Hi Jim,
|
| Thanks! Glad to hear that it works for you! At least I am going in the
| right direction.
| But would it surprise you if I say it jams now on?:
|
| Cell.FormulaArray = Cell.Formula
|
| ;o)
|
| I have no idea why it jams... (XL97-SR2)
| Sige
|




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default Rebuild Array-formulas

Thanks Tom,

Is it possible to adjust the code to make it work for multicell
array-formulas?

Sige

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Rebuild Array-formulas

Sige,

Below is some code that I wrote a long time ago (as a learning exercise) that updates any type of
formula in a workbook by changing a string (which could be a cell address, etc) within the formula.

You can at least see how to check for different types of formulas, and how to re-enter them.

HTH,
Bernie
MS Excel MVP

Option Explicit

'Declare constants for ReturnFormulaType function - assigned to FType
Const conMCAF As Integer = 1 ' con-stant Multi Cell Array Formula
Const conSCAF As Integer = 2 ' con-stant Single Cell Array Formula
Const conRF As Integer = 3 ' con-stant Regular Formula
Const conNF As Integer = 4 ' con-stant Non Formula
Public Const BoxTitle As String = "Formula Updater" ' Title for message boxes

'Dimension Global Variables
Dim FType As Integer
Dim myCell As Range

Sub UpdateFormulas()
Dim OldString As String
Dim NewString As String
Dim mySht As Worksheet

OldString = InputBox("Enter string to replace", BoxTitle)
NewString = InputBox("Enter replacement string", BoxTitle)

On Error Resume Next

For Each mySht In ActiveWorkbook.Worksheets
For Each myCell In mySht.Cells.SpecialCells(xlCellTypeFormulas)

If InStr(1, myCell.Formula, OldString) 1 Then

'Find out what type of formula it is
FType = ReturnFormulaType(myCell)

'Cell has a regular formula
If FType = conRF Then
myCell.Formula = _
Application.Substitute(myCell.Formula, _
OldString, NewString)
End If

'Cell has a Single Cell Array Formula
If FType = conSCAF Then
myCell.FormulaArray = _
Application.Substitute(myCell.FormulaArray, _
OldString, NewString)
End If

'Cell has a Multi-Cell Array Formula (is part of an array)
If FType = conMCAF Then
myCell.CurrentArray.FormulaArray = _
Application.Substitute(myCell.CurrentArray.Formula Array, _
OldString, NewString)
End If

End If

Next myCell

Next mySht

End Sub

Private Function ReturnFormulaType(inCell As Range) As Integer
'Function returns the type of formula in the passed cell
If inCell.HasArray Then
If inCell.CurrentArray.Address < inCell.Address Then
ReturnFormulaType = conMCAF 'Multi-Cell Array Formula
Else
ReturnFormulaType = conSCAF 'Single-Cell Array Formula
End If
Else
If inCell.HasFormula Then
ReturnFormulaType = conRF 'Regular Formula
Else
ReturnFormulaType = conNF 'No Formula
End If
End If
End Function









"Sige" wrote in message
ups.com...
Thanks Tom,

Is it possible to adjust the code to make it work for multicell
array-formulas?

Sige



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default Rebuild Array-formulas

Hi Bernie,

Cool funtion!
I do not manage to replace a string in a multi cell array formula
though. :o(

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
Convert Array Formulas to Regular Formulas Domenick Excel Worksheet Functions 6 August 17th 15 09:16 PM
Convert Array Formulas to Regular Formulas minyeh Excel Worksheet Functions 0 March 21st 10 05:55 AM
Need to rebuild formula using the value entered into a cell on the Forrest Excel Worksheet Functions 2 December 20th 05 05:07 PM
Break down, rebuild a matrix Possum Stu Excel Programming 2 April 11th 05 10:36 PM
Rebuild XL Worksheet Menu Bar hglamy[_2_] Excel Programming 2 September 2nd 03 06:28 PM


All times are GMT +1. The time now is 05:46 PM.

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"