+ Reply to Thread
Results 1 to 10 of 10

Parse text, include variable, compute it

  1. #1
    Registered User
    Join Date
    03-23-2017
    Location
    Belgium
    MS-Off Ver
    2010
    Posts
    21

    Parse text, include variable, compute it

    Hi All,

    I have zero knowledge in VBA, tried to find a solution to my problem with functions, unfortunately without success.

    I have an Excel sheet that contains text values, for example:
    Run for 5 mins at < 70% of a VAR> pace
    It could also contain < VMA70> < VMA/0.7> or < VMA>/0.7, but I guess that it's just a matter of "replace all".

    I would like to replace “< VAR>” by the content of a cell and compute it, for example above multiplied by 70%.
    Sometimes such a tag will even appear twice in 1 cell, and there might be carriage returns in cells.

    Problem is that the cell is text. I believe I actually need to:

    First replace the cell by something like:
    =”Run for 5 mins at “&< 70% of a VAR>&” pace”

    Then probably replace < 70% of a VAR> by < VAR>*70% to get:
    =”Run for 5 mins at “&< VAR>*70%&” pace”

    To finally replace < VAR> by a certain cell, let’s say H4, and force its evaluation:
    =”Run for 5 mins at “&H4*70%&” pace”

    If H4="05:10" the final text should then be ”Run for 5 mins at 07:23 pace”

    Note that I will also have to encode this in "mm:ss", so I will need something like TEXT(myresult,"mm:ss"), but I believe that won't be too much of an issue.

    Could you please help me understand if my reasoning is correct, and how I could proceed with such replacements to fix about many cells in 1 go?
    I will have about 50 cells to do in about 40 Excel tabs or files.

    Enclosed is my file for reference.

    Thanks a lot for your help as always!
    Attached Files Attached Files

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,926

    Re: Parse text, include variable, compute it

    Let me see if I understand the requirement.

    Cell D7 says:
    Warm up 20 Minutes
    2(8x200m+<VMA>/5)+02:00 at <VMA> min/km
    Cool down 15 min
    Let's say you reference cell K1 which has the value 10 in it. Would you like this to read
    Warm up 20 Minutes
    2(8x200m+10/5)+02:00 at 10 min/km
    Cool down 15 min
    Or do you want the calculation
    Warm up 20 Minutes
    2(8x200m+2)+02:00 at 10 min/km
    Cool down 15 min
    Or something else?
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    03-23-2017
    Location
    Belgium
    MS-Off Ver
    2010
    Posts
    21

    Re: Parse text, include variable, compute it

    Thanks a lot for the reply dflak!

    I confirm that the values should be calculated, so showing «*2*» and not «*10/5*».
    In my example from initial post, if I calculate 70%:
    If H4="05:10" the final text should then be ”Run for 5 mins at 07:23 pace”

    Thanks again!

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

    Re: Parse text, include variable, compute it

    Your explanation is not clear to me.

    If you upload a workbook with your exact desire result, it would help us to understand what you are trying to do.

  5. #5
    Registered User
    Join Date
    03-23-2017
    Location
    Belgium
    MS-Off Ver
    2010
    Posts
    21

    Re: Parse text, include variable, compute it

    Hi Jindon, thanks for your answer.
    Apologies, I thought it was attached but it actually wasn't.
    Enclosed is a sample file with first column containing the "raw" data and the second column with computed/expected results (done manually).
    I wish to be able to automatically generate the second column for all 40+ cells of the first column, and for about 50 Excel tabs....

    To explain my logic:
    All is based on cell H4 = 00:05:10 (5 min and 10 s). I need to derive percentages of this value in many calls, expressed like < VMA100> or as another example < VMA100>/5.
    < VMA100> means 100% of my variable H4. < VMA70> would mean 70% of that H4.
    2 examples, that I did manually:
    Footing 45 mins à < VMA70> min/km
    Should become
    Footing 45 mins à 07:23 min/km

    "Warm up 20 mins
    2x(8x200m+< VMA100>/5)+02:00 à < VMA100> min/km
    Cool down 15 mins"

    Should become:
    "Warm up 20 mins
    2x(8x200m+01:02)+02:00 à 05:10 min/km
    Cool down 15 mins"

    Thanks a lot,
    G
    Attached Files Attached Files

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

    Re: Parse text, include variable, compute it

    I don't think your calculation in E6, H4/0.7, should be H4*0.7.

    If correct, see if this calculates as you expected.
    Please Login or Register  to view this content.
    Last edited by jindon; 11-04-2018 at 11:13 PM.

  7. #7
    Registered User
    Join Date
    03-23-2017
    Location
    Belgium
    MS-Off Ver
    2010
    Posts
    21

    Re: Parse text, include variable, compute it

    It is /0.7 I swear! :-)

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

    Re: Parse text, include variable, compute it

    Then change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    03-23-2017
    Location
    Belgium
    MS-Off Ver
    2010
    Posts
    21

    Re: Parse text, include variable, compute it

    Thanks a lot guys, I will test tonight and will let you know the outcome!

  10. #10
    Registered User
    Join Date
    03-23-2017
    Location
    Belgium
    MS-Off Ver
    2010
    Posts
    21

    Re: Parse text, include variable, compute it

    Hi All,

    Sorry for the late feedback on this.
    Unfortunately the macro doesn't seem to work yet.
    I do see data copied from column D to column E, but my <*VMA> values that need to be calculated just remain <*VMA>

    One question for clarity, because I can't read the REGEXP well. If I want to compute (for example) "divided by 0.7", does the REGEXP expect <*VMA/0.7> or <*VMA>/0.7 (operation inside or outside the tag)?
    I can easily clean up all regexp to move the calucation inside or outside the tags, but at the moment none of the 2 get translated.

    Enclosed is my Excel sheet with macro included, would you be so kind to help me understand why REGEXP is not replaced?

    thanks again so much,
    G
    Attached Files Attached Files

+ 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. [SOLVED] Remove Blanc Space, parse text, convert text to measurement
    By plans in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-25-2015, 07:50 PM
  2. [SOLVED] Editing a Macro to include multiple rows and include text formatting for leading zeros
    By missmea2005 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-04-2014, 09:50 AM
  3. Compute New Variable(column) with If Statements - Like in SPSS/Stata/Etc.
    By as3ad in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-29-2014, 05:55 PM
  4. [SOLVED] Expand on Parse Function/ Column to Column - Contiguous Data to include quantities
    By arcamp in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-21-2013, 05:18 PM
  5. Macro to Parse Text - Import text to Excel from Multiple Text Files & Folders
    By Novice_To_Excel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-02-2012, 01:05 AM
  6. Parse items include repeat section headers
    By Leeb1800 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-12-2011, 02:07 PM
  7. using an address stored in a variable to compute the sum
    By dialerguy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-11-2005, 04:40 PM

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