+ Reply to Thread
Results 1 to 10 of 10

If a condition is met convert range to value from formula

  1. #1
    Registered User
    Join Date
    08-08-2012
    Location
    Winter Park, Florida
    MS-Off Ver
    Excel2010
    Posts
    12

    If a condition is met convert range to value from formula

    Good Afternoon All

    First I just want to thank everyone on here regardless of solution. I have been following this board for a while and this site has always helped me expand my knowledge of VBA. I am no expert by any means but i now enough to get myself into trouble.

    Image if you will of a spreadsheet where in column A you have a drop down with two options to pick from open and close.

    Columns B - E have formulas in them that pull from another sheet (specifically vlookup formulas)

    What i am trying to accomplish is this. If a person selects close from the drop down in column A, columns (B-E), on that row, gets converted from the vlookup formula to its value.

    I have tried writing this a number of way but either excel says that there is a problem with the code or i get the wrong result. I just can't seem to get it to specify to the specific rows that meet the condition. This is the closest working code that i have so far:

    Please Login or Register  to view this content.
    I have tried specifying range for rows but I am doing something wrong.

    If someone can help point me in the right direction with this that would be amazing.
    Thank you all.
    MG
    Last edited by Mothergreen; 01-10-2016 at 08:19 PM.

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: If a condition is met convert range to value from formula

    Post withdrawn
    Last edited by humdingaling; 01-10-2016 at 08:22 PM.
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Registered User
    Join Date
    08-08-2012
    Location
    Winter Park, Florida
    MS-Off Ver
    Excel2010
    Posts
    12

    Re: If a condition is met convert range to value from formula

    Adjusted sorry about that. First time posting code on the forum

  4. #4
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: If a condition is met convert range to value from formula

    The only thing I did was add
    Please Login or Register  to view this content.
    to your code and it seemed to work
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  5. #5
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: If a condition is met convert range to value from formula

    not a problem

    possible solution you can use below

    Please Login or Register  to view this content.
    Mock up file attached
    Attached Files Attached Files
    Last edited by humdingaling; 01-10-2016 at 08:48 PM. Reason: typo

  6. #6
    Registered User
    Join Date
    08-08-2012
    Location
    Winter Park, Florida
    MS-Off Ver
    Excel2010
    Posts
    12

    Re: If a condition is met convert range to value from formula

    I did that as well. Specifying the range and for it to specifically affect only the rows that meet the requirements still eludes me. Its either all or nothing when i specify a range either a excel says something is wrong with the range or at the first close it goes through the whole spreadsheet and changes all the formulas in rows B-E

  7. #7
    Registered User
    Join Date
    08-08-2012
    Location
    Winter Park, Florida
    MS-Off Ver
    Excel2010
    Posts
    12

    Re: If a condition is met convert range to value from formula

    Thank You Humdingaling this worked. This looks much simpler then what i was doing. I guess i have spent to much time learning from recording macros instead of branching out. I am going to try this code on a similar sheet that goes on for about 3000+ rows fingers crossed .

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: If a condition is met convert range to value from formula

    FWIW:

    Please Login or Register  to view this content.

  9. #9
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: If a condition is met convert range to value from formula

    just to explain my code further

    the "i" in my code represents the "current" row

    Please Login or Register  to view this content.
    so it starts from row one (i = 1) and loops until "ActiveSheet.UsedRange.Rows.Count" which should represent your last row
    this helps a bit in the code running faster so it doesnt loop for million+ rows

    syntax for cells (rows,columns)

    so this line
    Please Login or Register  to view this content.
    looks at column 1 which is A

    i = 1 then a1, i = 2 then a2, i = 3 then a3....etc

    rest of the code is self explanatory

    Please Login or Register  to view this content.
    this just copies the value and replaces with value ...its another way of doing pastespecial - values

  10. #10
    Registered User
    Join Date
    08-08-2012
    Location
    Winter Park, Florida
    MS-Off Ver
    Excel2010
    Posts
    12

    Thumbs up Re: If a condition is met convert range to value from formula

    Thank you all for your time and help. This is exactly what i needed and thank you for the amazingly quick reply. You all make this board awesome.

+ 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. VBA-Excel to convert Tax Formula with condition
    By Parth007 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 03-12-2015, 04:54 PM
  2. Replies: 2
    Last Post: 09-01-2014, 07:59 AM
  3. Need formula using 'If' condition & inserting a specific range.
    By andyzz in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 07-26-2014, 02:58 AM
  4. [SOLVED] Looping through a range and inserting a formula where condition met
    By strud in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-06-2014, 06:24 AM
  5. Formatting a range and Adding a formula to convert the range.
    By Technodruid in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-28-2010, 02:22 PM
  6. How to you convert condition to formula?
    By stormracela in forum Excel General
    Replies: 1
    Last Post: 05-27-2010, 05:18 AM
  7. Index Formula - adding a range condition
    By Henry c in forum Excel General
    Replies: 2
    Last Post: 04-29-2010, 10:19 AM

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