+ Reply to Thread
Results 1 to 2 of 2

Unable to record complicated formula in macro

  1. #1

    Unable to record complicated formula in macro

    I have a formula that requires to be entered as an array by
    CTRL+SHIFT+ENTER in order to execute correctly. I tried to record a
    macro with this formula, it says "unable to record macro". The
    following is an example of my formula:

    =1*MID(A1,MATCH(TRUE,ISNUMBER(1*MID(A1,ROW($1:$9),1)),0),COUNT(1*MID(A1,ROW($1:$9),1)))

    which can also be found here
    http://office.microsoft.com/en-us/as...549011033.aspx


    Any ideas around this?


  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Viduo,

    You can use a User Defined Function (UDF) in place of the Worksheet functions. Add a VBA module to your Workbook's Project and copy this code into it.

    Example of Uing the UDF:
    A1 = "abc123efg"
    B1 = "=GetNumbers(A1)"
    B1 will contain 123

    Public Function GetNumbers(ByRef Cell As Range)

    Application.Volatile

    Dim I As Long
    Dim N As Long
    Dim X As String

    For I = 1 To Len(Cell.Text)
    N = Asc(Mid(Cell.Text, I, 1))
    If N > 47 And N < 58 Then X = X & Chr$(N)
    Next I

    GetNumbers = X

    End Function

    Sincerely,
    Leith Ross

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1