+ Reply to Thread
Results 1 to 5 of 5

VBA: Count characters between parentheses in cell

  1. #1
    Registered User
    Join Date
    06-14-2017
    Location
    Mexico
    MS-Off Ver
    2010
    Posts
    3

    VBA: Count characters between parentheses in cell

    Hello ,

    I'm trying to count the number of character between parentheses in excel.
    I already have a code that count the number of characters on a cell, but then I have cells with boolean operators with parentheses "()&()".
    For example:

    Code Configurable item Value Comment
    GY Color 0 0 is for gray
    WH Color 1 1 is for white
    LT Weight 0,0,1 0x1 light weight
    HY Weight 0,1,0 0x2 heavy weight
    (GY)&(LT) Material 0,0,0,1 0x1 Al
    (WH)&((LT)|(HY)) Material 0,1,0,0 0x4 Ag
    ((WH)|(GY))&(HY) Material 1,0,0,0 0x8 Au


    My current macro count the number of characters (must be 2 on column "code" to be ok), and if it is more or less than 2 it fills the cell with red.
    I can't make the code to count inside the "(" ")", currently I'm ignoring the cells with parentheses.

    I found a formula: =Mid(A1, Find("(", A1)+1, Find(")",A1)-Find("(",A1)-1)
    But as I have several parentheses it does not work and also I'm trying to add it to my current macro.

    I'm thinking of using string variables to save the values for example in ((WH)|(GY))&(HY):
    Val1= WH
    Val2 = GY
    Val3 = HY

    Any idea how I can do it?

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,588

    Re: VBA: Count characters between parentheses in cell

    What do you really want to do?

    Just count the characters or extract the characters?

  3. #3
    Registered User
    Join Date
    06-14-2017
    Location
    Mexico
    MS-Off Ver
    2010
    Posts
    3

    Re: VBA: Count characters between parentheses in cell

    Count the characters between each parentheses. For example:

    ((WH)|(GY))&(HY)

    The first "string" to count would be "WH", then "GY" and then "HY"

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,588

    Re: VBA: Count characters between parentheses in cell

    I don't think it is clear.
    Is it total of 6 or 2,2,2 ?

    Upload a workbook with data and the result that you want to avoid misunderstanding.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  5. #5
    Registered User
    Join Date
    06-14-2017
    Location
    Mexico
    MS-Off Ver
    2010
    Posts
    3

    Re: VBA: Count characters between parentheses in cell

    SOLVED:

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Count if cell contains one or more characters
    By tywlam in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-22-2016, 10:44 PM
  2. Executing methods - parentheses or no parentheses?
    By dmasters4919 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-23-2015, 07:57 PM
  3. [SOLVED] Count No. of characters in a cell
    By nagesh.tvsr in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-13-2014, 05:02 AM
  4. [SOLVED] Can I count characters in a cell
    By tuph in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-26-2014, 10:09 PM
  5. [SOLVED] Extracting all text from parentheses (including parentheses)
    By j4ke101 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 05-10-2013, 08:03 AM
  6. Replies: 6
    Last Post: 01-13-2011, 03:00 AM
  7. Count Characters in a Cell
    By TOTO_POP in forum Excel General
    Replies: 2
    Last Post: 08-06-2010, 06:03 AM

Tags for this Thread

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