Results 1 to 10 of 604

Thread: Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,468
    Rep Power
    10
    This is post 23187
    https://www.excelfox.com/forum/showt...ll=1#post23187
    https://www.excelfox.com/forum/showt...ge59#post23187






    The new solution
    Having done all the donkey work, and now, knowing probably better than anyone what it is all about we can go straight into some solutions.
    Code:
     Sub SimplerSolutionDevelopment()    '     https://www.excelfox.com/forum/showthread.php/2909-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=23187&viewfull=1#post23187
    Rem 0 test data range
    Dim Ws1 As Worksheet
     Set Ws1 = ThisWorkbook.Worksheets("Sheet1")
    Dim Rng As Range
     Set Rng = Worksheets.Item("Sheet1").Range("A1:F7")
    Rem 1
    Rng.Offset(0, Rng.Columns.Count + 1).Clear
    
    '1a These do nothing, and we know why now   https://www.excelfox.com/forum/showthread.php/2918-Right-Hand-Side-Range-Range-Value-values-Range-Range-Value-only-sometimes-Range-Range-Value-Anomaly?p=23192&viewfull=1#post23192
     Let Rng.Offset(0, Rng.Columns.Count + 1) = Range("A1:F7")
     Let Rng.Offset(0, Rng.Columns.Count + 1) = Evaluate("A1:F7")
    '1b(i) a trick will do it
    ' Let Rng.Offset(0, Rng.Columns.Count + 1) = Range("IF({1},A1:F7)") ' Run time error  '1004'
     Let Rng.Offset(0, Rng.Columns.Count + 1) = Evaluate("IF({1},A1:F7)")
     'Watch : - : Evaluate("IF({1},A1:F7)") :  : Variant/Variant(1 to 7, 1 to 6) : Sheet1.SimplerSolutionDevelopment
    '                              
    '1b(ii)
     Let Rng.Offset(0, Rng.Columns.Count + 1) = Evaluate("IF(A1:F7="""","""",IF({1},A1:F7))")
    ' Watch : + : Evaluate("IF(A1:F7="""","""",IF({1},A1:F7))") :  : Variant/Variant(1 to 7, 1 to 6) : Sheet1.SimplerSolutionDevelopment
    '                              
    
    '1b(iii)
     Rng.Offset(0, Rng.Columns.Count + 1).Clear
     Let Rng.Offset(0, Rng.Columns.Count + 1) = Evaluate("IF(A1:F7="""","""",A1:F7)")
    ' Watch : + : Evaluate("IF(A1:F7="""","""",A1:F7)") :  : Variant/Variant(1 to 7, 1 to 6) : Sheet1.SimplerSolutionDevelopment
    '                              
    
    
    '1c)
     Rng.Offset(0, Rng.Columns.Count + 1).Clear
     Let Rng.Offset(0, Rng.Columns.Count + 1) = Range("A1:F7").Value(RangeValueDataType:=xlRangeValueDefault)
     ' Watch : + : Range("A1:F7").Value :  : Variant/Variant(1 to 7, 1 to 6) : Sheet1.SimplerSolutionDevelopment
     '                             
     Rng.Offset(0, Rng.Columns.Count + 1).Clear
     Let Rng.Offset(0, Rng.Columns.Count + 1) = Evaluate("A1:F7").Value(RangeValueDataType:=xlRangeValueDefault)
     ' Watch : + : Evaluate("A1:F7").Value :  : Variant/Variant(1 to 7, 1 to 6) : Sheet1.SimplerSolutionDevelopment
     '                             
    End Sub



    Conclusions / A final solution(s)

    In the coding above, we do a very simple trick in '1b(i) to get the array of values passed to the LHS, this sort of thing
    Range2 = Evaluate("IF({1},A1:F7)")

    Code:
    
    .
    .
    .
    .
    ..
    .
    .
    .
    .
    ..
    .
    .
    .
    .
    ..
    .
    .
    .


    That is OK, it almost gets what we want, but we see that we have the problem of just an empty cell returning 0 in the tweaked Evaluate(" ") solution, https://i.postimg.cc/4NF4tH97/proble...d-Evaluate.jpg
    : Evaluate("IF({1},A1:F7)")(2,6) : 0 : Variant/Double : Sheet1.SimplerSolutionDevelopment
    : Evaluate("IF({1},A1:F7)")(3,6) : 0 : Variant/Double : Sheet1.SimplerSolutionDevelopment


    We had this problem in the original solution as well, https://eileenslounge.com/viewtopic....309137#p309137 ,….. If you have any cells in the selection that are empty, then you had better use this next version instead, or else it will change empty cells into a cell with a 0 in it …..
    This is perhaps understandable because we are doing mathematical calculations in VBA in Variants, and I am taking a guess that VBA calculations default to 0. Or some similar explanation.
    As in the original solution, we can remove that problem by a modification, as in '1b(ii) , so we have like
    Range2 = Evaluate("IF(A1:F7="""","""",IF({1},A1:F7))")
    In fact, as we often find, the extra bit does the trick, so we can remove the IF({1},____) and so simplify the solution to like as in '1b(iii)
    Range2 = Evaluate("IF(A1:F7="""","""",A1:F7)")
    ( One small thing to note with '1b(ii) and '1b(iii) is that the Empty is replace by / shown as "" , a zero length String ""
    : Evaluate("IF(A1:F7="""","""",IF({1},A1:F7))")(2,6) : "" : Variant/String : Sheet1.SimplerSolutionDevelopment
    : Evaluate("IF(A1:F7="""","""",IF({1},A1:F7))")(3,6) : "" : Variant/String : Sheet1.SimplerSolutionDevelopment
    : Evaluate("IF(A1:F7="""","""",A1:F7)")(2,6) : "" : Variant/String : Sheet1.SimplerSolutionDevelopment
    : Evaluate("IF(A1:F7="""","""",A1:F7)")(3,6) : "" : Variant/String : Sheet1.SimplerSolutionDevelopment )

    _.______________________

    Well, we got as far as we did before with the original solution, but done it correctly this time.
    But we can do another offering:
    See next post
    Last edited by DocAElstein; 08-14-2023 at 04:29 PM.

Similar Threads

  1. Testing Concatenating with styles
    By DocAElstein in forum Test Area
    Replies: 2
    Last Post: 12-20-2020, 02:49 AM
  2. testing
    By Jewano in forum Test Area
    Replies: 7
    Last Post: 12-05-2020, 03:31 AM
  3. Replies: 18
    Last Post: 03-17-2019, 06:10 PM
  4. Concatenating your Balls
    By DocAElstein in forum Excel Help
    Replies: 26
    Last Post: 10-13-2014, 02:07 PM
  5. Replies: 1
    Last Post: 12-04-2012, 08:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •