+ Reply to Thread
Results 1 to 33 of 33

Evaluate formula values to column help

  1. #1
    Registered User
    Join Date
    03-21-2021
    Location
    London
    MS-Off Ver
    2013
    Posts
    13

    Evaluate formula values to column help

    Good afternoon Experts

    I have some experience in formulas but am struggling with the Evaluate Function.
    I have this code that fills a column with a formula.Is there a way to make use of Evaluate Function and pass the values directly to the column.
    Please Login or Register  to view this content.
    Something like this perhaps?
    With Range("D2:D" & lastrow)
    .Value = Evaluate("=IF(COUNTIF(A2:C" & lastrow & ",""X"")> 0,""T"",""F"")")
    End With

    But this does not work
    Attached Files Attached Files
    Last edited by NeedForEXcell; 03-21-2021 at 10:38 AM.

  2. #2
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,512

    Re: Evaluate formula values to column help

    If the sub you have already works and you want the calculated values rather than the formulas in the cells then you could add one line to convert them to values after calculation.

    Please Login or Register  to view this content.
    Does that do what you need?

    BSB

  3. #3
    Registered User
    Join Date
    03-21-2021
    Location
    London
    MS-Off Ver
    2013
    Posts
    13

    Re: Evaluate formula values to column help

    Hallo BSB

    Thank you for your quick response. I was hoping to bypass the formulation and get the values directly to the column without the .Formula & .value conversion. I want the Formula answer to be Evaluated and directly passed as values.

  4. #4
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,164

    Re: Evaluate formula values to column help

    How about
    Please Login or Register  to view this content.

  5. #5
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,512

    Re: Evaluate formula values to column help

    You could calculate the results in memory and stamp those to the cells, but this isn't going to be any quicker than the code above.
    If anything it would be slower as you'll end up looping through each row in the range.

    BSB

  6. #6
    Registered User
    Join Date
    03-21-2021
    Location
    London
    MS-Off Ver
    2013
    Posts
    13

    Re: Evaluate formula values to column help

    Oh wow. Yes, Fluff13, that changed version works.Thank you.
    Just out of curiosity, is there a way to evaluate the countif row(range) of x > 0

    Something like this perhaps?

    Please Login or Register  to view this content.
    Last edited by NeedForEXcell; 03-21-2021 at 11:16 AM.

  7. #7
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,164

    Re: Evaluate formula values to column help

    AFAIK you cannot use countif(s) with evaluate.

  8. #8
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,505

    Re: Evaluate formula values to column help

    ....Deleted...
    Tried SUMPRODUCT to no avail...
    Last edited by Sintek; 03-21-2021 at 11:57 AM.
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  9. #9
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,164

    Re: Evaluate formula values to column help

    Yes I think you will, I know of no other way of doing that with evaluate.

  10. #10
    Registered User
    Join Date
    03-21-2021
    Location
    London
    MS-Off Ver
    2013
    Posts
    13

    Re: Evaluate formula values to column help

    That is odd. I just had a post disappear. Ghost in machine.
    Check Columns A to K
    Okay. Thank you Fluff13. Will go and add the 10 strings.
    Please Login or Register  to view this content.
    I am guessing post 2 Solution is not looking so bad then ha ha.
    Last edited by NeedForEXcell; 03-21-2021 at 12:14 PM.

  11. #11
    Registered User
    Join Date
    03-21-2021
    Location
    London
    MS-Off Ver
    2013
    Posts
    13

    Re: Evaluate formula values to column help

    One last question if I may. In the attached green highlighted. I have placed COUNTIF Formula & Corresponding SUMPRODUCT Formula to produce the same result.

    As one is not able to make use of COUNTIF (As per Fluff13) or SUMPRODUCT (As per sintek's attempt) with the Evaluate function, How would one populate these results with the Evaluate Value Function in VBA.

    This is giving me sleepless nights ha ha.
    Attached Files Attached Files
    Last edited by NeedForEXcell; 03-22-2021 at 04:44 AM.

  12. #12
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,164

    Re: Evaluate formula values to column help

    I would just put the formula in & then convert to values.

  13. #13
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,505

    Re: Evaluate formula values to column help

    @ NeedForEXcell...

    I make use of post 2 option most times...
    I guess even if what you were asking was doable, it would not make much change in efficiency...

    And if one of our most seasoned coders cannot do it, then nobody can...

  14. #14
    Registered User
    Join Date
    03-21-2021
    Location
    London
    MS-Off Ver
    2013
    Posts
    13

    Re: Evaluate formula values to column help

    "one of our most seasoned coders"

    Is that you sintek?
    Okay, thank you for your input Gents(Not sure if you are - or ladies perhaps?)
    Anyway, will mark as solved and chalk it up as a "not possible"

  15. #15
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,505

    Re: Evaluate formula values to column help

    Is that you sintek?
    No, not at all...I am still learning new ways to do things everyday...That is why I love this forum so much...Was referring to Fluff13

  16. #16
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,164

    Re: Evaluate formula values to column help

    Like sintek I also learn new ways to do things from other members here.
    Often times the simplest way is the best, why re-invent the wheel?

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

    Re: Evaluate formula values to column help

    Quote Originally Posted by NeedForEXcell View Post
    Something like this perhaps?
    With Range("D2:D" & lastrow)
    .Value = Evaluate("=IF(COUNTIF(A2:C" & lastrow & ",""X"")> 0,""T"",""F"")")
    End With

    But this does not work
    Please Login or Register  to view this content.

  18. #18
    Registered User
    Join Date
    03-21-2021
    Location
    London
    MS-Off Ver
    2013
    Posts
    13

    Re: Evaluate formula values to column help

    Oh my gosh! That works jindon
    Have no idea what it does. Straight over my head.
    I was looking into array slicing but could not understand it well.
    Evaluate("if(countif(offset(" & x & ",row(1:" & .Rows.Count & ")-1,,1,2),""X""),""T"",""F"")")

    The red part is that ref B2:C5
    What about the blue part if you don't mind me asking. This is fantastic.

  19. #19
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,505

    Re: Evaluate formula values to column help

    Like sintek I also learn new ways to do things from other members here.
    And look at that...once again...jindon to the rescue...and so we learn...All in a days work

    Well that solves your initial requirement...Not sure about your duplicate count in 11...perhaps jindon has a fix for that too!

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

    Re: Evaluate formula values to column help

    OFFSET(range, rows, columns, [height], [width] )

    1 is for height (each row), 2 is for width (b:c)

    HTH

  21. #21
    Registered User
    Join Date
    03-21-2021
    Location
    London
    MS-Off Ver
    2013
    Posts
    13

    Re: Evaluate formula values to column help

    | Yes --- Thank You |

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

    Re: Evaluate formula values to column help

    Quote Originally Posted by NeedForEXcell View Post
    One last question if I may. In the attached green highlighted. I have placed COUNTIF Formula & Corresponding SUMPRODUCT Formula to produce the same result.
    Simply
    Please Login or Register  to view this content.

  23. #23
    Registered User
    Join Date
    03-21-2021
    Location
    London
    MS-Off Ver
    2013
    Posts
    13

    Re: Evaluate formula values to column help

    Quote Originally Posted by jindon View Post
    Simply
    Please Login or Register  to view this content.
    I must be doing something wrong. That produces values of 3 all down.
    Evaluate("countif(" & .Address & "," & .Address & ")")
    The red part is ref to A10:A17
    Formula is ref to each individual cell in range
    =COUNTIF(A$10:A$17,A10)
    Last edited by NeedForEXcell; 03-22-2021 at 11:11 AM.

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

    Re: Evaluate formula values to column help

    Try the attached.
    Attached Files Attached Files

  25. #25
    Registered User
    Join Date
    03-21-2021
    Location
    London
    MS-Off Ver
    2013
    Posts
    13

    Re: Evaluate formula values to column help

    It populates all with 2's

    Untitled.png

  26. #26
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,332

    Re: Evaluate formula values to column help

    You won't get the results you want without the Offset that jindon used originally.
    Everyone who confuses correlation and causation ends up dead.

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

    Re: Evaluate formula values to column help

    Perhaps version difference
    try
    Please Login or Register  to view this content.

  28. #28
    Registered User
    Join Date
    03-21-2021
    Location
    London
    MS-Off Ver
    2013
    Posts
    13

    Re: Evaluate formula values to column help

    Quote Originally Posted by rorya View Post
    You won't get the results you want without the Offset that jindon used originally.
    This produces errors
    Please Login or Register  to view this content.

  29. #29
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,332

    Re: Evaluate formula values to column help

    Ignore me - I hadn't seen that what you wanted in the green section is very different from your original question.

  30. #30
    Registered User
    Join Date
    03-21-2021
    Location
    London
    MS-Off Ver
    2013
    Posts
    13

    Re: Evaluate formula values to column help

    Quote Originally Posted by jindon View Post
    Perhaps version difference
    try
    Please Login or Register  to view this content.
    Yes. jindon. that works. I am also using 2013 though.

    May I ask why the 2 commas. Is that same as 1,1 row & col

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

    Re: Evaluate formula values to column help

    That was
    OFFSET(range, rows, columns, [height], [width] )

    Number of row(s), column(s) to be offset from the base range,
    Default value = 0
    So, offsetting by Row(1:" & .Rows.Count & ")-1 means Row(0:.Rows.Count -1)

    BTW, I'm testing on O365...

  32. #32
    Registered User
    Join Date
    03-21-2021
    Location
    London
    MS-Off Ver
    2013
    Posts
    13

    Re: Evaluate formula values to column help

    Understood. I honestly did not think this could be done. Now to measure the efficiency of Formula, Evaluate & Array loops.
    I am certain I'll be back with another post soon ha ha. Thank you all for your interest and a big THANK you to you jindon.

    365. Yes, guess that is version compatibility

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

    Re: Evaluate formula values to column help

    Ahhh, comma at the end of Index function...
    These are row/column reference within the range/array.
    When these are 0, default value, it returns full value.

+ 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] Evaluate values within a chart
    By plans in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-23-2019, 03:22 PM
  2. [SOLVED] Fill column using evaluate
    By KingTamo in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-20-2018, 09:19 AM
  3. Replies: 11
    Last Post: 12-17-2018, 02:17 PM
  4. Replies: 2
    Last Post: 05-23-2013, 01:00 PM
  5. Assigning variable values using the Evaluate() function
    By gladst_j in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-09-2011, 04:51 AM
  6. I Need a formula to evaluate a cell with + or - values
    By Bob in Oklahoma in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-31-2005, 11:05 AM
  7. [SOLVED] evaluate cell values
    By [email protected] in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-19-2005, 07:05 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