Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Thủ tục này có chứa mã, không tìm thấy trong các thủ tục khác trong cuốn sách này, cho phép các vĩ mô để chấp nhận một phương trình đa thức như một tham chiếu đến một ô có chứa công thức hoặc là một tham chiếu đến một tế bào có chứa một công thức như văn bản. | 170 EXCEL NUMERICAL METHODS This procedure contains code not found in other procedures in this book that allows the macro to accept a polynomial equation as a reference to a cell that contains a formula or as a reference to a cell that contains a formula as text. The procedure also handles an implicit reference. Option Explicit Function Bairstow equation reference Obtains the coefficients of a regular polynomial maximum order 6 . Polynomial is a cell formula. Polynomial can contain cell references or names. Poynomial can be text. Reference can be a cell reference or a name. Dim A As Double Root As Double Dim J As Integer N As Integer Dim p1 As Integer p2 As Integer p3 As Integer Dim expnumber As Integer ParenFlag As Integer Dim R As Integer c As Integer Dim FormulaText As string RefText As string NameText As string Dim char As string term As string ReDim A 6 GET equation EITHER AS CELL FORMULA OR AS TEXT. If Application.IsText equation Then FormulaText equation If in quotes remove them. If Asc Left FormulaText 1 34 Then _ FormulaText Mid FormulaText 2 Len FormulaText -1 Else FormulaText equation.Formula EndIf If Left FormulaText 1 Then FormulaText Mid FormulaText 2 1024 FormulaText Application.ConvertFormula FormulaText xlA1 XIA1 _ xIAbsolute FormulaText Application.Substitute FormulaText remove all spaces GET THE NAME CORRESPONDING TO reference NameText On Error Resume Next Handles case where no name has been assigned NameText reference.Name.Name On Error GoTo 0 NameText Mid NameText lnStr 1 NameText I 1 HANDLE CASE WHERE reference IS A RANGE by finding cell in same row or column as cell containing function. If reference.Rows.Count 1 Then R equation.Row Set reference lntersect reference Range R R Elself reference.Columns.Count 1 Then c equation.Column Set reference lntersect reference Range C C CHAPTER 8 ROOTS OF EQUATIONS 171 End If RefText reference. Address PARSE THE FORMULA INTO TERMS pointers p1 beginning p2 end of string. FormulaText FormulaText .add extra .