+ Reply to Thread
Results 1 to 5 of 5

Help, please, with extracting numbers from strings in VBA

  1. #1
    Registered User
    Join Date
    10-04-2013
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2007
    Posts
    7

    Help, please, with extracting numbers from strings in VBA

    Hi, All,

    If someone could help, I'd really appreciate it,

    I have about 24 Workbooks with 12-14 sheets that have a row which contains weights entered as formulas to display the total of two weights, e.g.,
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    ,
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    , etc. Some cells in the rows are empty, so I'm trying to loop thru the ranges and parse out the two figures on separate lines, e.g. if Cell E2 has
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    , I'd like to get E2 to have "1664" and E3 to have "281" as values. I've already figured out how to consolidate the rows from the various worksheets into one Sheet and replicate the rows for the parsed values, but trying to figure out the VBA is getting me stuck. I've tried the following code, could someone please have a look and see what I'm doing wrong? A sample workbook is also included with attached macro.

    Please Login or Register  to view this content.
    201201MonthlyHelp.xlsm

    Thanks for any helpful suggestions!

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,631

    Re: Help, please, with extracting numbers from strings in VBA

    Please Login or Register  to view this content.
    Last edited by protonLeah; 10-22-2013 at 12:27 AM.
    Ben Van Johnson

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Help, please, with extracting numbers from strings in VBA

    Another one.

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  4. #4
    Registered User
    Join Date
    10-04-2013
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Help, please, with extracting numbers from strings in VBA

    Wow, THANKS, Y'all, BOTH solutions work like a charm! Guess I have a long way to go and a lot to learn...

    Alpha, am I correct in guessing the v variant is creating an array? That's something I've read about, but had no idea how to implement, thanks for the tip!

    I'm not worthy, I'm not worthy.... but workin on it!

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Help, please, with extracting numbers from strings in VBA

    You're welcome.

    Quote Originally Posted by shennin202 View Post
    Alpha, am I correct in guessing the v variant is creating an array? That's something I've read about, but had no idea how to implement, thanks for the tip!
    The Split command returns an array. The v variable of type Variant receives the result.

+ 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. extracting numbers from alphanumeric strings
    By brockk in forum Excel Formulas & Functions
    Replies: 25
    Last Post: 08-22-2016, 10:43 PM
  2. Extracting numbers from inconsistent text strings
    By netguru in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-25-2012, 03:20 AM
  3. Extracting Numbers From Strings
    By ross88guy in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-21-2010, 05:37 PM
  4. extracting strings and numbers from one cell into seperate cells??
    By zivlaz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-05-2010, 12:03 PM
  5. [SOLVED] 2 more questions about extracting numbers from text strings
    By andy from maine in forum Excel General
    Replies: 0
    Last Post: 03-28-2005, 05:06 PM

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