Results 1 to 10 of 603

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,316
    Rep Power
    10
    In support of this forum post
    https://eileenslounge.com/viewtopic.php?f=30&t=38895

    This is Hans final working Solution
    Code:
     '    Hans   https://eileenslounge.com/viewtopic.php?p=300746#p300746
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim Rng As Range, Pee As String
    On Error GoTo Myerror
     Let Application.EnableEvents = False
    '    If Not Intersect(Target, Columns(1)) Is Nothing Then
            For Each Rng In Intersect(Target, Columns(1))
             Let Pee = Replace(Replace(Evaluate("Proper(""" & Rng.Value & """)"), " ", ""), "-", "")
                Select Case Pee
                    Case "A"
                     Let Rng.Value = "ABC"
                    Case "Aa"
                     Let Rng.Value = "XXD"
                    Case Else
                     Rng.ClearContents
                End Select
            Next Rng
    '    End If
    Myerror:
     Let Application.EnableEvents = True
    End Sub
    


    We can pretty this via Evaluate Range up in two main ways
    _ The VBA Replace ideas can be replaced in the Evaluate by Excel spreadsheet SUBSTITUTE
    _ The VBA Select Case ideas can be replaced by the Excel spreadsheet IF

    The full coding example here follows approximately the Excel spreadsheet workings in the uploaded file. (In that file my workings are for the example range D11:D12 being copied and pasted into column 1, range A11:A12)
    Note that in some steps the trick IF({1},___) was needed to get more than one result, but it was often found that in subsequent steps this could be removed. I expect this is because whatever phenomena is going on in that trick, goes on when we introduce steps involving IFs on multi cell ranges, so then the trick is redundant.

    Code:
    Private Sub Worksheet_Change(ByVal Target As Range)  '   https://excelfox.com/forum/showthread.php/2834-Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=19028&viewfull=1#post19028
    Dim Pee As String '  , Rng As Range
    On Error GoTo Myerror
     Let Application.EnableEvents = False
        If Not Intersect(Target, Columns(1)) Is Nothing Then
        Dim varTest As Variant
         Let varTest = Evaluate("=IF({1},PROPER(" & Target.Address & "))")
         Let varTest = Evaluate("=IF({1},SUBSTITUTE(IF({1},PROPER(" & Target.Address & ")),"" "",""""))")
         Let varTest = Evaluate("=IF({1},SUBSTITUTE(PROPER(" & Target.Address & "),"" "",""""))")
         Let varTest = Evaluate("=IF({1},SUBSTITUTE(SUBSTITUTE(PROPER(" & Target.Address & "),"" "",""""),""-"",""""))")
         Let varTest = Evaluate("=IF(IF({1},SUBSTITUTE(SUBSTITUTE(PROPER(" & Target.Address & "),"" "",""""),""-"",""""))=""A"",""ABC"",""x"")")
         Let varTest = Evaluate("=IF(SUBSTITUTE(SUBSTITUTE(PROPER(" & Target.Address & "),"" "",""""),""-"","""")=""A"",""ABC"",""x"")")
         Let varTest = Evaluate("=IF(SUBSTITUTE(SUBSTITUTE(PROPER(" & Target.Address & "),"" "",""""),""-"","""")=""A"",""ABC"",IF(SUBSTITUTE(SUBSTITUTE(PROPER(" & Target.Address & "),"" "",""""),""-"","""")=""Aa"",""XXD"",""""))")
         'Let Target.Value2 = varTest
         Let Target.Value2 = Evaluate("=IF(SUBSTITUTE(SUBSTITUTE(PROPER(" & Target.Address & "),"" "",""""),""-"","""")=""A"",""ABC"",IF(SUBSTITUTE(SUBSTITUTE(PROPER(" & Target.Address & "),"" "",""""),""-"","""")=""Aa"",""XXD"",""""))")
    '        For Each Rng In Intersect(Target, Columns(1))
    '         Let Pee = Replace(Replace(Evaluate("Proper(""" & Rng.Value & """)"), " ", ""), "-", "")
    '            Select Case Pee
    '                Case "A"
    '                 Let Rng.Value = "ABC"
    '                Case "Aa"
    '                 Let Rng.Value = "XXD"
    '                Case Else
    '                 Rng.ClearContents
    '            End Select
    '        Next Rng
        Else
        ' case not pasted in column 1
        End If
    Myerror:
     Let Application.EnableEvents = True
    End Sub
    
    Attached Files Attached Files
    Last edited by DocAElstein; 11-08-2022 at 03:42 PM.
    ….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
    If you are my enemy, we will try to kick the fucking shit out of you…..
    Winston Churchill, 1939
    Save your Forum..._
    _...KILL A MODERATOR!!

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
  •