+ Reply to Thread
Results 1 to 4 of 4

Extracting values from a string with VBA

  1. #1
    Registered User
    Join Date
    09-25-2012
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    3

    Extracting values from a string with VBA

    I need to extract a number from a string which is written in a cell.
    For example:
    • A1 contains the text: 74 Upper specification limit of product
    • A2 contains the text: 70 Lower specification limit of product
    • A3 contains the text: 72 Nominal value required
    • A4 contains the text: 5 % defects accepted in product
    • A5 contains the text: 8 number of items per sample required

    I need to use the numbers (74, 70, 72, 5, 8) as variables in calculations later on in my code.
    For example:
    • USL = 74
    • LSL = 70
    • Nom = 72
    • Def = 5
    • n = 8

    How do I go about stepping through each cell and extraction the numbers and saving them as variables? I would probably use the space after each number as the break point but I am new fairly inexperianced with VBA and I'm not sure how to do this.

    Solved with:
    Please Login or Register  to view this content.
    Last edited by BaconOke; 09-25-2012 at 08:53 AM. Reason: Solved

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Extracting values from a string with VBA

    try something like
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    09-25-2012
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Extracting values from a string with VBA

    Thanks for the reply. Unfortunately that returns a value of 0. I am currently trying something like this:
    Please Login or Register  to view this content.
    But I get an error in line 4 "Invalid procedure or call argument"

  4. #4
    Registered User
    Join Date
    09-25-2012
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Extracting values from a string with VBA

    Solved with:
    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)

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