Page 45 of 55 FirstFirst ... 354344454647 ... LastLast
Results 441 to 450 of 541

Thread: Appendix Thread. 3 *

  1. #441
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,429
    Rep Power
    10
    This is a slightly more sane version of the single line macro idea from here
    https://excelfox.com/forum/showthrea...ll=1#post15420
    https://excelfox.com/forum/showthrea...ll=1#post15421


    Code:
    Sub SlightlySanerVersion()
    Dim arrStrTemp() As String: Let arrStrTemp() = Split(Replace(Replace(Join(Application.Index(Evaluate("=IF(ISERROR(MATCH(F2:F463,C2:C463*($A$2:$A$1000=$I$1),0)*($A$2:$A$1000=$I$1)),ROW(F2:F463),0)"), Evaluate("=column(A:QT)"), Evaluate("=column(A:QT)/column(A:QT)")), "#"), "0#", ""), "#0", ""), "#")
    Dim arrTemp() As Variant:  Let arrTemp() = Application.Index(Worksheets("Sheet1").Columns(6), Application.Index(arrStrTemp(), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")/row(1:" & UBound(arrStrTemp()) + 1 & ")"), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")")), 1)
     
     Let Range("T2").Resize(UBound(arrTemp(), 1), 1).Value = arrTemp()
    Stop
     Range("T2").Resize(UBound(arrTemp(), 1), 1).ClearContents
    ' Or
    Dim UnicNm As String: Let UnicNm = "aa"
     Let arrStrTemp() = Split(Replace(Replace(Join(Application.Index(Evaluate("=IF(ISERROR(MATCH(F2:F463,C2:C463*($A$2:$A$1000=" & """" & UnicNm & """" & "),0)*($A$2:$A$1000=$I$1)),ROW(F2:F463),0)"), Evaluate("=column(A:QT)"), Evaluate("=column(A:QT)/column(A:QT)")), "#"), "0#", ""), "#0", ""), "#")
     Let arrTemp() = Application.Index(Worksheets("Sheet1").Columns(6), Application.Index(arrStrTemp(), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")/row(1:" & UBound(arrStrTemp()) + 1 & ")"), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")")), 1)
     
     Let Range("T2").Resize(UBound(arrTemp(), 1), 1).Value = arrTemp()
    End Sub
    We can use the basic idea above to make a function idea to do the same

    Code:
    Sub UseNotSoInsaneFunction()
    Dim arrTemp() As Variant
     Let arrTemp() = NotSoInsane("aa")
     Range("T2").Resize(UBound(arrTemp(), 1), 1).ClearContents
     Let Range("T2").Resize(UBound(arrTemp(), 1), 1).Value = arrTemp()
    End Sub
    
    
    Function NotSoInsane(ByVal Nme As String) As Variant
    Dim arrStrTemp() As String: Let arrStrTemp() = Split(Replace(Replace(Join(Application.Index(Evaluate("=IF(ISERROR(MATCH(F2:F463,C2:C463*($A$2:$A$1000=" & """" & Nme & """" & "),0)*($A$2:$A$1000=$I$1)),ROW(F2:F463),0)"), Evaluate("=column(A:QT)"), Evaluate("=column(A:QT)/column(A:QT)")), "#"), "0#", ""), "#0", ""), "#")
    Dim arrTemp() As Variant: Let arrTemp() = Application.Index(Worksheets("Sheet1").Columns(6), Application.Index(arrStrTemp(), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")/row(1:" & UBound(arrStrTemp()) + 1 & ")"), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")")), 1)
     Let NotSoInsane = arrTemp()
    End Function
    
    
    
    
    ….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!!

  2. #442
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,429
    Rep Power
    10
    In support of these Threads and posts
    https://excelfox.com/forum/showthrea...ll=1#post15421
    http://www.eileenslounge.com/viewtopic.php?f=30&t=36224


    A problem arose with testing with bb

    _____ Workbook: Extract missing dates for each person bb.xlsm ( Using Excel 2007 32 bit )
    Row\Col T U V W X Y Z
    1 Yasser Given Hans Results Indicies
    2 2021-01-26 2021-01-29 2021-01-29 2
    3 2021-01-30 2021-01-30 0
    4 2021-02-05 2021-02-05 0
    5 2021-01-29 2021-02-12 2021-02-12 5
    6 2021-01-30 2021-01-26 2021-01-26 6
    7 2021-01-29 2021-01-29 0
    8 2021-01-30 2021-01-30 0
    9 2021-02-02 2021-02-02 2021-02-02 9
    10 2021-02-05 0
    11 2021-02-12 0
    12 2021-02-05 2021-02-05 12
    13 2021-02-16 0
    14 2021-02-19 0
    15 2021-02-25 0
    16 0
    17 0
    18 0
    19 2021-02-12 2021-02-12 19
    20 2021-02-13 20
    21 0
    22 2021-02-15 22
    23 2021-02-16 2021-02-16 23
    24 0
    25 0
    26 2021-02-19 2021-02-19 26
    27 0
    28 0
    29 0
    30 0
    31 0
    32 2021-02-25 2021-02-25 32
    33 2021-01-29 0
    Worksheet: Sheet1

    If you examine above my ( wrong) results in column T against Hans results in column V and
    then look at the Debug / Immediate window info below for
    before ( http://i.imgur.com/M3laahV.jpg )
    and
    after ( http://i.imgur.com/RUPIWIg.jpg ), where I take out the unwanted data from a text string , .._
    Code:
     ? strtemp
    2#0#0#5#6#0#0#9#0#0#12#0#0#0#0#0#0#19#20#0#22#23#0#0#26#0#0#0#0#0#32#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0
    
    ? strtemp
    2#5#6#9#12#19#222#23#26#32
    _...then I can see the problem and where its coming from:

    The problem is that I chose to remove the unwanted data
    _ first by removing all #0 - that works fine, no problem with that as I am not expecting any real data starting with a 0
    _ second I allow for the case of unwanted data at the start by removing all 0# - this can cause problems as it has in this example – It has resulted for example in this
    #20#0#22
    becoming this
    #20#22
    And then when after , (or previously) the 0# is removed/ was removed, the final result is
    #222
    So I loose the valid data of 20 and 22 and get a wrong data of 222 ( and in the test data, indicial 222 matches to an empty cell )
    The final outcome is I loose two final date values and gain an extra unwanted empty ( nonsense date zero value ) date


    There are thousands of easy ways to solve this problem , with various If Then ways. But these will “interrupt the flow” as it were, leading to inefficiency and prevent me building my final one line code way.

    This first element problem is one I often refer to as an awkward bollock
    Variations of this come up a lot. Often an efficient cure to this awkward bollock is to include an extra separator at the start. This wont quite for us in the case of this data, but almost.
    The following variation seems OK
    Consider these two lines, where the awkward bollock is dealt with second
    Code:
     ' The next few lines get rid of the  0s
    Dim StrTemp As String: Let StrTemp = Join(arrTemp(), "#") ' Convert the array to a string with a  #  in between each data
     Let StrTemp = Replace(StrTemp, "#0", "", 2, -1, vbBinaryCompare): StrTemp = Replace(StrTemp, "0#", "", 1, -1, vbBinaryCompare) ' This effectively removes the  0s   data ( and its seperator ) 
    Solution:
    I add some arbitrary character at the start
    StrTemp = "_" & Join(arrTemp(), "#")
    That wont add much extra overhead
    Now deal with the awkward bollock first
    StrTemp = Replace(StrTemp, "_0#", "_" ………..
    That has done no extra work, just done an existing step a bit differently

    So far nothing so clever. The next part allows us to do no, or little, extra work by taking advantage of a little known extra argument of the Replace
    The forth (optional) argument of Replace lets us say at which character point in the original we start our returned string. That may confuse, so let me say that again with an example..
    I have this xy-z-2 and I want this yz2
    Most people would think they need
    either
    _ two Replaces , one to take out – and the other to take out x
    or
    _ a Replace to take out – and then some other process or function to take out the first character.

    But if we choose 2 in our forth argument of the Replace that takes out the - , then our returned string will effectively have the first character removed.
    Code:
     ' The next few lines get rid of the  0s
    Dim StrTemp As String: Let StrTemp = "_" & Join(arrTemp(), "#") ' Convert the array to a string with a  #  in between each data
     Let StrTemp = Replace(StrTemp, "_0#", "_", 1, 1, vbBinaryCompare): StrTemp = Replace(StrTemp, "#0", "", 2, -1, vbBinaryCompare) ' This effectiveely removes the  0s   data ( and its seperator )
     
    That seems to solve the problem
    strTempAfterProblemSolved.JPG


    Full macro in next post
    ….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!!

  3. #443
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,429
    Rep Power
    10
    Full macro for last post

    Code:
    Sub Pretty3bbProbSolved()  '  https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=15426&viewfull=1#post15426
    Dim arrTemp() As Variant
    Rem  To get the results in  column  T  ( same as
     ' Ths first forumula give me all the matches for F in the C ( helper column )  or error for no match
     Let arrTemp() = Evaluate("=If({1},MATCH(F2:F463,C2:C463,0))")   '   If({1},____)    may not be needed for Excel 2016 and higher   The first formula does the main work
     ' The multiplication by $A$2:$A$1000=$I$1 limits the range used by effectively making 0 check dates outside or range of interest
     Let arrTemp() = Evaluate("=IF({1},MATCH(F2:F463,C2:C463*($A$2:$A$1000=$I$1),0))")   '  $A$2:$A$1000=$I$1 gives us an array full of  Falses and Trues , which Excel will interpret mathematically as 0 or 1   This has the effect of giving us a 0 multiplyer on numbers outside our range of interst, so in total a 0 for outside our range of interest.   Our range of interest gets a 1 multiplier so has therefore no change and we can find those numbers whereas we wont find a 0, well actually we will find a zero if the range to search for has a zero as it does further down, so we take care of that in the next line
     ' The above formula has one problem with the supplied data in that empty cells are seen in this formula as 0 which gives a match
     Let arrTemp() = Evaluate("=IF(F2:F463=0,0,MATCH(F2:F463,C2:C463*($A$2:$A$1000=$I$1),0))")   '   In looking in the range to find a match in ( the range to be searched we have all 0s outside the range caused by the previous $A$2:$A$1000=$I$1  So the first of these 0s will be seen as the match cell for all cells in  F  that are empty.  So i take care here of the situation where an empty cell in  F  is by  giving a  0  output   So far two things retrn me a zero.   You often find in formula building that the coercing  If({1},___) suddenly is not needed. Her we find that the newly used here  IF(F2:F463=0,0,___)  is doing the required co oecing
     ' we will now do a simple  If(ISERROR( ) , Row( ) , 0 ) on the above . This will give us a row indicie for the missing data,  and  a  0  for the found data
     Let arrTemp() = Evaluate("=IF(ISERROR(MATCH(F2:F463,C2:C463*($A$2:$A$1000=$I$1),0)*($A$2:$A$1000=$I$1)),ROW(F2:F463),0)")
     ' At this point we have wanted data or zeros. I want to conveniently use some VB string fuction whuch annoyingly onl work on 1 D arrays, so we convert it by a transpose in the next code line
     Let arrTemp() = Application.Index(arrTemp(), Evaluate("=column(A:QT)"), Evaluate("=column(A:QT)/column(A:QT)"))
     ' Or
     Let arrTemp() = Application.Index(Evaluate("=IF(ISERROR(MATCH(F2:F463,C2:C463*($A$2:$A$1000=$I$1),0)*($A$2:$A$1000=$I$1)),ROW(F2:F463),0)"), Evaluate("=column(A:QT)"), Evaluate("=column(A:QT)/column(A:QT)"))
     
     ' The next few lines get rid of the  0s
    Dim StrTemp As String: Let StrTemp = "_" & Join(arrTemp(), "#") ' Convert the array to a string with a  #  in between each data
     Let StrTemp = Replace(StrTemp, "_0#", "_", 1, 1, vbBinaryCompare): StrTemp = Replace(StrTemp, "#0", "", 2, -1, vbBinaryCompare) ' This effectiveely removes the  0s   data ( and its seperator )
    Dim arrStrTemp() As String: Let arrStrTemp() = Split(StrTemp, "#", -1, vbBinaryCompare) ' remake the array
    ' Or
    Let arrStrTemp() = Split(Replace(Replace("_" & Join(Application.Index(Evaluate("=IF(ISERROR(MATCH(F2:F463,C2:C463*($A$2:$A$1000=$I$1),0)*($A$2:$A$1000=$I$1)),ROW(F2:F463),0)"), Evaluate("=column(A:QT)"), Evaluate("=column(A:QT)/column(A:QT)")), "#"), "_0#", "_"), "#0", "", 2), "#")
     ' We need a "vertical" array for output, so we  transpose
     Let arrTemp() = Application.Index(arrStrTemp(), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")/row(1:" & UBound(arrStrTemp()) + 1 & ")"), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")"))
     Let arrTemp() = Application.Index(Worksheets("Sheet1").Columns(6), arrTemp(), 1) ' finally we want the  dates  ( so far we have the row indicies obtained from  Match   Note. this formula has the problem that we get the results  a row out of step... Its actually very convenient because if i use  Cells typically, here a column  then I have a nice solution
    ' Or
     Let arrTemp() = Application.Index(Worksheets("Sheet1").Columns(6), Application.Index(arrStrTemp(), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")/row(1:" & UBound(arrStrTemp()) + 1 & ")"), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")")), 1) ' finally we want the  dates  ( so far we have the row indicies obtained from  Match   Note. this formula has the problem that we get the results  a row out of step... Its actually very convenient because if i use  Cells typically, here a column  then I have a nice solution
     
     Let Range("T2").Resize(UBound(arrTemp(), 1), 1).Value = arrTemp()
     Let Range("T2").Resize(UBound(arrTemp(), 1), 1).NumberFormat = "yyyy/mm/dd" '  from macro recorder .NumberFormat = "[$-1010000]yyyy/mm/dd,@"
    
    Stop
     Range("T2").Resize(UBound(arrTemp(), 1), 1).ClearContents
     
    ' Or
     Let arrStrTemp() = Split(Replace(Replace("_" & Join(Application.Index(Evaluate("=IF(ISERROR(MATCH(F2:F463,C2:C463*($A$2:$A$1000=$I$1),0)*($A$2:$A$1000=$I$1)),ROW(F2:F463),0)"), Evaluate("=column(A:QT)"), Evaluate("=column(A:QT)/column(A:QT)")), "#"), "_0#", "_"), "#0", "", 2), "#")
     Let arrTemp() = Application.Index(Worksheets("Sheet1").Columns(6), Application.Index(arrStrTemp(), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")/row(1:" & UBound(arrStrTemp()) + 1 & ")"), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")")), 1) ' finally we want the  dates  ( so far we have the row indicies obtained from  Match   Note. this formula has the problem that we get the results  a row out of step... Its actually very convenient because if i use  Cells typically, here a column  then I have a nice solution
     Let Range("T2").Resize(UBound(arrTemp(), 1), 1).Value = arrTemp()
     ' Or
     Range("T2").Resize(UBound(arrTemp(), 1), 1).ClearContents
     Let Range("T2").Resize(UBound(Application.Index(Worksheets("Sheet1").Columns(6), Application.Index(Split(Replace(Replace("_" & Join(Application.Index(Evaluate("=IF(ISERROR(MATCH(F2:F463,C2:C463*($A$2:$A$1000=$I$1),0)*($A$2:$A$1000=$I$1)),ROW(F2:F463),0)"), Evaluate("=column(A:QT)"), Evaluate("=column(A:QT)/column(A:QT)")), "#"), "_0#", "_"), "#0", "", 2), "#", -1), Evaluate("=row(1:" & UBound(Split(Replace(Replace("_" & Join(Application.Index(Evaluate("=IF(ISERROR(MATCH(F2:F463,C2:C463*($A$2:$A$1000=$I$1),0)*($A$2:$A$1000=$I$1)),ROW(F2:F463),0)"), Evaluate("=column(A:QT)"), Evaluate("=column(A:QT)/column(A:QT)")), "#"), "_0#", "_"), "#0", "", 2), "#", -1)) + 1 & ")/row(1:" & UBound(Split(Replace(Replace("_" & Join(Application.Index(Evaluate("=IF(ISERROR(MATCH(F2:F463,C2:C463*($A$2:$A$1000=$I$1),0)*($A$2:$A$1000=$I$1)),ROW(F2:F463),0)"), _
     Evaluate("=column(A:QT)"), Evaluate("=column(A:QT)/column(A:QT)")), "#"), "_0#", "_"), "#0", "", 2), "#", -1)) + 1 & ")"), Evaluate("=row(1:" & UBound(Split(Replace(Replace("_" & Join(Application.Index(Evaluate("=IF(ISERROR(MATCH(F2:F463,C2:C463*($A$2:$A$1000=$I$1),0)*($A$2:$A$1000=$I$1)),ROW(F2:F463),0)"), Evaluate("=column(A:QT)"), Evaluate("=column(A:QT)/column(A:QT)")), "#"), "_0#", "_"), "#0", "", 2), "#", -1)) + 1 & ")")), 1), 1), 1).Value = _
     Application.Index(Worksheets("Sheet1").Columns(6), Application.Index(Split(Replace(Replace("_" & Join(Application.Index(Evaluate("=IF(ISERROR(MATCH(F2:F463,C2:C463*($A$2:$A$1000=$I$1),0)*($A$2:$A$1000=$I$1)),ROW(F2:F463),0)"), Evaluate("=column(A:QT)"), Evaluate("=column(A:QT)/column(A:QT)")), "#"), "_0#", "_"), "#0", "", 2), "#", -1), Evaluate("=row(1:" & UBound(Split(Replace(Replace("_" & Join(Application.Index(Evaluate("=IF(ISERROR(MATCH(F2:F463,C2:C463*($A$2:$A$1000=$I$1),0)*($A$2:$A$1000=$I$1)),ROW(F2:F463),0)"), Evaluate("=column(A:QT)"), Evaluate("=column(A:QT)/column(A:QT)")), "#"), "_0#", "_"), "#0", "", 2), "#", -1)) + 1 & ")/row(1:" & UBound(Split(Replace(Replace("_" & Join(Application.Index(Evaluate("=IF(ISERROR(MATCH(F2:F463,C2:C463*($A$2:$A$1000=$I$1),0)*($A$2:$A$1000=$I$1)),ROW(F2:F463),0)"), _
     Evaluate("=column(A:QT)"), Evaluate("=column(A:QT)/column(A:QT)")), "#"), "_0#", "_"), "#0", "", 2), "#", -1)) + 1 & ")"), Evaluate("=row(1:" & UBound(Split(Replace(Replace("_" & Join(Application.Index(Evaluate("=IF(ISERROR(MATCH(F2:F463,C2:C463*($A$2:$A$1000=$I$1),0)*($A$2:$A$1000=$I$1)),ROW(F2:F463),0)"), Evaluate("=column(A:QT)"), Evaluate("=column(A:QT)/column(A:QT)")), "#"), "_0#", "_"), "#0", "", 2), "#", -1)) + 1 & ")")), 1)
     
    End Sub
    ….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!!

  4. #444
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,429
    Rep Power
    10
    I am not quite sure what got in my brain in the last post. With hind site most of what I said and done is crap. But maybe later I will twig to what was going on.

    I will start again…. Or rather pick it up where I went off course…._ I have …_
    _.... an awkward bollock
    Variations of this come up a lot. Often an efficient cure to this awkward bollock is to include an extra separator at the start.

    The general solution is fine. After adding a separator, #, at the start, I remove all #0
    All is well and then I only need to get rid finally of a single # I don’t need at the start.
    For that last thing, Mid(StrTemp,2) would do. So would a second Replace in this form Replace(StrTemp, "#", "", 1, 1…. Or Replace(StrTemp, "#", "", , 1….
    In the Replace.. we are using the 5th (optional ) argument to restrict us to removing a single # and the convention is to start from the left so that will hit on the first.

    In this complete version I use the Mid(StrTemp,2) way

    Code:
    Option Explicit
    Sub Pretty3bbaa()  '
    Dim arrTemp() As Variant
    Rem  To get the results in  column  T  ( same as Yassers or Hans Results
     ' Ths first forumula gives me all the matches for F in the C ( helper column )  or error for no match
     Let arrTemp() = Evaluate("=If({1},MATCH(F2:F463,C2:C463,0))")   '   If({1},____)    may not be needed for Excel 2016 and higher   The first formula does the main work
     ' The multiplication by $A$2:$A$1000=$I$1 limits the range used by effectively making 0 check dates outside or range of interest
     Let arrTemp() = Evaluate("=IF({1},MATCH(F2:F463,C2:C463*($A$2:$A$1000=$I$1),0))")   '  $A$2:$A$1000=$I$1 gives us an array full of  Falses and Trues , which Excel will interpret mathematically as 0 or 1   This has the effect of giving us a 0 multiplyer on numbers outside our range of interst, so in total a 0 for outside our range of interest.   Our range of interest gets a 1 multiplier so has therefore no change and we can find those numbers whereas we wont find a 0, well actually we will find a zero if the range to search for has a zero as it does further down, so we take care of that in the next line
     ' The above formula has one problem with the supplied data in that empty cells are seen in this formula as 0 which gives a match
     Let arrTemp() = Evaluate("=IF(F2:F463=0,0,MATCH(F2:F463,C2:C463*($A$2:$A$1000=$I$1),0))")   '   In looking in the range to find a match in ( the range to be searched we have all 0s outside the range caused by the previous $A$2:$A$1000=$I$1  So the first of these 0s will be seen as the match cell for all cells in  F  that are empty.  So i take care here of the situation where an empty cell in  F  is by  giving a  0  output   So far two things retrn me a zero.   You often find in formula building that the coercing  If({1},___) suddenly is not needed. Her we find that the newly used here  IF(F2:F463=0,0,___)  is doing the required co oecing
     ' we will now do a simple  If(ISERROR( ) , Row( ) , 0 ) on the above . This will give us a row indicie for the missing data,  and  a  0  for the found data
     Let arrTemp() = Evaluate("=IF(ISERROR(MATCH(F2:F463,C2:C463*($A$2:$A$1000=$I$1),0)*($A$2:$A$1000=$I$1)),ROW(F2:F463),0)")
     ' At this point we have wanted data or zeros. I want to conveniently use some VB string fuction whuch annoyingly onl work on 1 D arrays, so we convert it by a transpose in the next code line
     Let arrTemp() = Application.Index(arrTemp(), Evaluate("=column(A:QT)"), Evaluate("=column(A:QT)/column(A:QT)"))
     ' Or
     Let arrTemp() = Application.Index(Evaluate("=IF(ISERROR(MATCH(F2:F463,C2:C463*($A$2:$A$1000=$I$1),0)*($A$2:$A$1000=$I$1)),ROW(F2:F463),0)"), Evaluate("=column(A:QT)"), Evaluate("=column(A:QT)/column(A:QT)"))
     
     ' The next few lines get rid of the  0s   ( 2 lines commented out to prevent the shortened line messing up )
    Dim StrTemp As String: Let StrTemp = "#" & Join(arrTemp(), "#") ' Convert the array to a string with a  #  in between each data.  The extra # allows us to remove all  0  entries via removing all  #0  Without this we might get one left at the start
    ' Let StrTemp = Replace(StrTemp, "#0", "", 1, -1, vbBinaryCompare) ' This effectiveely removes the  0s   data ( and its seperator )
    ' Let StrTemp = Mid(StrTemp, 2) '  Because I omit the third optional ( length ) argument I get all the remaing string after the first one. This effectively takes off the extra  #  which I don't need
    Dim arrStrTemp() As String: Let arrStrTemp() = Split(StrTemp, "#", -1, vbBinaryCompare) ' remake the array
    ' Or ,
    Let arrStrTemp() = Split(Mid(Replace("#" & Join(Application.Index(Evaluate("=IF(ISERROR(MATCH(F2:F463,C2:C463*($A$2:$A$1000=$I$1),0)*($A$2:$A$1000=$I$1)),ROW(F2:F463),0)"), Evaluate("=column(A:QT)"), Evaluate("=column(A:QT)/column(A:QT)")), "#"), "#0", ""), 2), "#")
     ' We need a "vertical" array for output, so we  transpose
     Let arrTemp() = Application.Index(arrStrTemp(), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")/row(1:" & UBound(arrStrTemp()) + 1 & ")"), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")"))
     Let arrTemp() = Application.Index(Worksheets("Sheet1").Columns(6), arrTemp(), 1) ' finally we want the  dates  ( so far we have the row indicies obtained from  Match   Note. this formula has the problem that we get the results  a row out of step... Its actually very convenient because if i use  Cells typically, here a column  then I have a nice solution
    ' Or
     Let arrTemp() = Application.Index(Worksheets("Sheet1").Columns(6), Application.Index(arrStrTemp(), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")/row(1:" & UBound(arrStrTemp()) + 1 & ")"), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")")), 1) ' finally we want the  dates  ( so far we have the row indicies obtained from  Match   Note. this formula has the problem that we get the results  a row out of step... Its actually very convenient because if i use  Cells typically, here a column  then I have a nice solution
    '
     Let Range("T2").Resize(UBound(arrTemp(), 1), 1).Value = arrTemp()
     Let Range("T2").Resize(UBound(arrTemp(), 1), 1).NumberFormat = "yyyy/mm/dd" '  from macro recorder .NumberFormat = "[$-1010000]yyyy/mm/dd,@"
    
    Stop
     Range("T2").Resize(UBound(arrTemp(), 1), 1).ClearContents
      
    End Sub
    Sub SlightlySanerVersion()
    Dim arrStrTemp() As String: Let arrStrTemp() = Split(Mid(Replace("#" & Join(Application.Index(Evaluate("=IF(ISERROR(MATCH(F2:F463,C2:C463*($A$2:$A$1000=$I$1),0)*($A$2:$A$1000=$I$1)),ROW(F2:F463),0)"), Evaluate("=column(A:QT)"), Evaluate("=column(A:QT)/column(A:QT)")), "#"), "#0", ""), 2), "#")
    Dim arrTemp() As Variant:  Let arrTemp() = Application.Index(Worksheets("Sheet1").Columns(6), Application.Index(arrStrTemp(), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")/row(1:" & UBound(arrStrTemp()) + 1 & ")"), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")")), 1)
      Let Range("T2").Resize(UBound(arrTemp(), 1), 1).Value = arrTemp()
    Stop
     Range("T2").Resize(UBound(arrTemp(), 1), 1).ClearContents
    ' Or
    Dim UnicNm As String: Let UnicNm = "aa" ' "aa"
     Let arrStrTemp() = Split(Mid(Replace("#" & Join(Application.Index(Evaluate("=IF(ISERROR(MATCH(F2:F463,C2:C463*($A$2:$A$1000=" & """" & UnicNm & """" & "),0)*($A$2:$A$1000=" & """" & UnicNm & """" & ")),ROW(F2:F463),0)"), Evaluate("=column(A:QT)"), Evaluate("=column(A:QT)/column(A:QT)")), "#"), "#0", ""), 2), "#")
     Let arrTemp() = Application.Index(Worksheets("Sheet1").Columns(6), Application.Index(arrStrTemp(), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")/row(1:" & UBound(arrStrTemp()) + 1 & ")"), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")")), 1)
     Let Range("T2").Resize(UBound(arrTemp(), 1), 1).Value = arrTemp()
    End Sub
    ….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!!

  5. #445
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,429
    Rep Power
    10
    I can sanitise the last version a bit and come up with a simple function to get you an array of your missings, where the function takes the unique name, ( the unique name in the test data is the things like aa bb cc etc. )

    Code:
    Sub SlightlySanerVersion()
    Dim arrStrTemp() As String: Let arrStrTemp() = Split(Mid(Replace("#" & Join(Application.Index(Evaluate("=IF(ISERROR(MATCH(F2:F463,C2:C463*($A$2:$A$1000=$I$1),0)*($A$2:$A$1000=$I$1)),ROW(F2:F463),0)"), Evaluate("=column(A:QT)"), Evaluate("=column(A:QT)/column(A:QT)")), "#"), "#0", ""), 2), "#")
    Dim arrTemp() As Variant:  Let arrTemp() = Application.Index(Worksheets("Sheet1").Columns(6), Application.Index(arrStrTemp(), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")/row(1:" & UBound(arrStrTemp()) + 1 & ")"), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")")), 1)
      Let Range("T2").Resize(UBound(arrTemp(), 1), 1).Value = arrTemp()
    Stop
     Range("T2").Resize(UBound(arrTemp(), 1), 1).ClearContents
    ' Or
    Dim UnicNm As String: Let UnicNm = "aa" ' "aa"
     Let arrStrTemp() = Split(Mid(Replace("#" & Join(Application.Index(Evaluate("=IF(ISERROR(MATCH(F2:F463,C2:C463*($A$2:$A$1000=" & """" & UnicNm & """" & "),0)*($A$2:$A$1000=" & """" & UnicNm & """" & ")),ROW(F2:F463),0)"), Evaluate("=column(A:QT)"), Evaluate("=column(A:QT)/column(A:QT)")), "#"), "#0", ""), 2), "#")
     Let arrTemp() = Application.Index(Worksheets("Sheet1").Columns(6), Application.Index(arrStrTemp(), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")/row(1:" & UBound(arrStrTemp()) + 1 & ")"), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")")), 1)
     Let Range("T2").Resize(UBound(arrTemp(), 1), 1).Value = arrTemp()
    End Sub
    Sub UseNotSoInsaneFunction()
    Dim arrTemp() As Variant
     Let arrTemp() = NotSoInsane("bb")
     ' Columns("T:T").ClearContents  ' Range("T2").Resize(UBound(arrTemp(), 1), 1).ClearContents
     Let Range("T2").Resize(UBound(arrTemp(), 1), 1).Value = arrTemp()
     Let Range("T2").Resize(UBound(arrTemp(), 1), 1).NumberFormat = "yyyy/mm/dd"
    End Sub
    Function NotSoInsane(ByVal Nme As String) As Variant
    Dim arrStrTemp() As String: Let arrStrTemp() = Split(Mid(Replace("#" & Join(Application.Index(Evaluate("=IF(ISERROR(MATCH(F2:F463,C2:C463*($A$2:$A$1000=" & """" & Nme & """" & "),0)*($A$2:$A$1000=" & """" & Nme & """" & ")),ROW(F2:F463),0)"), Evaluate("=column(A:QT)"), Evaluate("=column(A:QT)/column(A:QT)")), "#"), "#0", ""), 2), "#")
    Dim arrTemp() As Variant: Let arrTemp() = Application.Index(Worksheets("Sheet1").Columns(6), Application.Index(arrStrTemp(), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")/row(1:" & UBound(arrStrTemp()) + 1 & ")"), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")")), 1)
     Let NotSoInsane = arrTemp()
    End Function
     '



    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    https://www.youtube.com/watch?v=tzbKqTRuRzU&lc=UgyYW2WZ2DvSrzUKnJ14AaABAg
    https://www.youtube.com/watch?v=UywjKEMjSp0&lc=UgxIySxHPqM1RxtVqoR4AaABAg.9edGvmwOLq99eekDyfS0 CD
    https://www.youtube.com/watch?v=UywjKEMjSp0&lc=UgxIySxHPqM1RxtVqoR4AaABAg.9edGvmwOLq99eevG7txd 2c
    https://www.youtube.com/watch?v=SIDLFRkUEIo&lc=UgzTF5vvB67Zbfs9qvx4AaABAg
    https://www.youtube.com/watch?v=9P6r7DLS77Q&lc=UgzytUUVRyw9U55-6M54AaABAg
    https://www.youtube.com/watch?v=9P6r7DLS77Q&lc=UgzCoa6tOVIBxRDDDbN4AaABAg
    https://www.youtube.com/watch?v=9P6r7DLS77Q&lc=UgyriWOelbVnw4FHWT54AaABAg.9dPo-OdLmZ09dc21kigjmr
    https://www.youtube.com/watch?v=363wd2EtQZ0&lc=UgzDQfo5rJqyVwvv2r54AaABAg
    https://www.youtube.com/watch?v=363wd2EtQZ0&lc=UgzHTSka7YppBdmUooV4AaABAg.9cXui6zzkz09cZttH_-2Gf
    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    ….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!!

  6. #446
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,429
    Rep Power
    10
    Post for later use
    ….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!!

  7. #447
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,429
    Rep Power
    10
    If I use a Transpose function at one place instead of my preferred Index way of transposing things, then I can reduce it to a single code line: This for example will get your pasted results for the unique “aa” Missings
    Code:
    Sub SingleLineWithTranspose()
     Let Range("T2").Resize(UBound(Application.Index(Worksheets("Sheet1").Columns(6), Application.Transpose(Split(Mid(Replace("#" & Join(Application.Index(Evaluate("=IF(ISERROR(MATCH(F2:F463,C2:C463*($A$2:$A$1000=$I$1),0)*($A$2:$A$1000=$I$1)),ROW(F2:F463),0)"), Evaluate("=column(A:QT)"), Evaluate("=column(A:QT)/column(A:QT)")), "#"), "#0", ""), 2), "#")), 1), 1), 1).Value = Application.Index(Worksheets("Sheet1").Columns(6), Application.Transpose(Split(Mid(Replace("#" & Join(Application.Index(Evaluate("=IF(ISERROR(MATCH(F2:F463,C2:C463*($A$2:$A$1000=$I$1),0)*($A$2:$A$1000=$I$1)),ROW(F2:F463),0)"), Evaluate("=column(A:QT)"), Evaluate("=column(A:QT)/column(A:QT)")), "#"), "#0", ""), 2), "#")), 1)
    End Sub

    Here are some of the full workings used to get that single code line:

    Code:
    Sub Pretty3bbaaTranspose()  '
    Dim arrTemp() As Variant
    Rem  To get the results in  column  T  ( same as Yassers or hans Results
     ' Ths first forumula gives me all the matches for F in the C ( helper column )  or error for no match
     Let arrTemp() = Evaluate("=If({1},MATCH(F2:F463,C2:C463,0))")   '   If({1},____)    may not be needed for Excel 2016 and higher   The first formula does the main work
     ' The multiplication by $A$2:$A$1000=$I$1 limits the range used by effectively making 0 check dates outside or range of interest
     Let arrTemp() = Evaluate("=IF({1},MATCH(F2:F463,C2:C463*($A$2:$A$1000=$I$1),0))")   '  $A$2:$A$1000=$I$1 gives us an array full of  Falses and Trues , which Excel will interpret mathematically as 0 or 1   This has the effect of giving us a 0 multiplyer on numbers outside our range of interst, so in total a 0 for outside our range of interest.   Our range of interest gets a 1 multiplier so has therefore no change and we can find those numbers whereas we wont find a 0, well actually we will find a zero if the range to search for has a zero as it does further down, so we take care of that in the next line
     ' The above formula has one problem with the supplied data in that empty cells are seen in this formula as 0 which gives a match
     Let arrTemp() = Evaluate("=IF(F2:F463=0,0,MATCH(F2:F463,C2:C463*($A$2:$A$1000=$I$1),0))")   '   In looking in the range to find a match in ( the range to be searched we have all 0s outside the range caused by the previous $A$2:$A$1000=$I$1  So the first of these 0s will be seen as the match cell for all cells in  F  that are empty.  So i take care here of the situation where an empty cell in  F  is by  giving a  0  output   So far two things retrn me a zero.   You often find in formula building that the coercing  If({1},___) suddenly is not needed. Her we find that the newly used here  IF(F2:F463=0,0,___)  is doing the required co oecing
     ' we will now do a simple  If(ISERROR( ) , Row( ) , 0 ) on the above . This will give us a row indicie for the missing data,  and  a  0  for the found data
     Let arrTemp() = Evaluate("=IF(ISERROR(MATCH(F2:F463,C2:C463*($A$2:$A$1000=$I$1),0)*($A$2:$A$1000=$I$1)),ROW(F2:F463),0)")
     ' At this point we have wanted data or zeros. I want to conveniently use some VB string fuction whuch annoyingly onl work on 1 D arrays, so we convert it by a transpose in the next code line
     Let arrTemp() = Application.Index(arrTemp(), Evaluate("=column(A:QT)"), Evaluate("=column(A:QT)/column(A:QT)"))
     ' Or
     Let arrTemp() = Application.Index(Evaluate("=IF(ISERROR(MATCH(F2:F463,C2:C463*($A$2:$A$1000=$I$1),0)*($A$2:$A$1000=$I$1)),ROW(F2:F463),0)"), Evaluate("=column(A:QT)"), Evaluate("=column(A:QT)/column(A:QT)"))
     
     ' The next few lines get rid of the  0s   ( 2 lines commented out to prevent the shortened line messing up )
    Dim StrTemp As String: Let StrTemp = "#" & Join(arrTemp(), "#") ' Convert the array to a string with a  #  in between each data.  The extra # allows us to remove all  0  entries via removing all  #0  Without this we might get one left at the start
    ' Let StrTemp = Replace(StrTemp, "#0", "", 1, -1, vbBinaryCompare) ' This effectiveely removes the  0s   data ( and its seperator )
    ' Let StrTemp = Mid(StrTemp, 2) '  Because I omit the third optional ( length ) argument I get all the remaing string after the first one. This effectively takes off the extra  #  which I don't need
    Dim arrStrTemp() As String: Let arrStrTemp() = Split(StrTemp, "#", -1, vbBinaryCompare) ' remake the array
    ' Or ,
    Let arrStrTemp() = Split(Mid(Replace("#" & Join(Application.Index(Evaluate("=IF(ISERROR(MATCH(F2:F463,C2:C463*($A$2:$A$1000=$I$1),0)*($A$2:$A$1000=$I$1)),ROW(F2:F463),0)"), Evaluate("=column(A:QT)"), Evaluate("=column(A:QT)/column(A:QT)")), "#"), "#0", ""), 2), "#")
     
     
     ' We need a "vertical" array for output, so we  transpose
     Let arrTemp() = Application.Transpose(arrStrTemp())
     Let arrTemp() = Application.Index(Worksheets("Sheet1").Columns(6), arrTemp(), 1) ' finally we want the  dates  ( so far we have the row indicies obtained from  Match   Note. this formula has the problem that we get the results  a row out of step... Its actually very convenient because if i use  Cells typically, here a column  then I have a nice solution
    ' Or
     Let arrTemp() = Application.Index(Worksheets("Sheet1").Columns(6), Application.Transpose(arrStrTemp()), 1) ' finally we want the  dates  ( so far we have the row indicies obtained from  Match   Note. this formula has the problem that we get the results  a row out of step... Its actually very convenient because if i use  Cells typically, here a column  then I have a nice solution
    ' Or
     Let arrTemp() = Application.Index(Worksheets("Sheet1").Columns(6), Application.Transpose(Split(Mid(Replace("#" & Join(Application.Index(Evaluate("=IF(ISERROR(MATCH(F2:F463,C2:C463*($A$2:$A$1000=$I$1),0)*($A$2:$A$1000=$I$1)),ROW(F2:F463),0)"), Evaluate("=column(A:QT)"), Evaluate("=column(A:QT)/column(A:QT)")), "#"), "#0", ""), 2), "#")), 1)
    
     
     Let Range("T2").Resize(UBound(Application.Index(Worksheets("Sheet1").Columns(6), Application.Transpose(Split(Mid(Replace("#" & Join(Application.Index(Evaluate("=IF(ISERROR(MATCH(F2:F463,C2:C463*($A$2:$A$1000=$I$1),0)*($A$2:$A$1000=$I$1)),ROW(F2:F463),0)"), Evaluate("=column(A:QT)"), Evaluate("=column(A:QT)/column(A:QT)")), "#"), "#0", ""), 2), "#")), 1), 1), 1).Value = Application.Index(Worksheets("Sheet1").Columns(6), Application.Transpose(Split(Mid(Replace("#" & Join(Application.Index(Evaluate("=IF(ISERROR(MATCH(F2:F463,C2:C463*($A$2:$A$1000=$I$1),0)*($A$2:$A$1000=$I$1)),ROW(F2:F463),0)"), Evaluate("=column(A:QT)"), Evaluate("=column(A:QT)/column(A:QT)")), "#"), "#0", ""), 2), "#")), 1)
     Let Range("T2").Resize(UBound(arrTemp(), 1), 1).NumberFormat = "yyyy/mm/dd" '  from macro recorder .NumberFormat = "[$-1010000]yyyy/mm/dd,@"
    
    
    Stop
    ' Range("T2").Resize(UBound(arrTemp(), 1), 1).ClearContents
      
    End Sub
    Sub SingleLineWithTranspose()
     Let Range("T2").Resize(UBound(Application.Index(Worksheets("Sheet1").Columns(6), Application.Transpose(Split(Mid(Replace("#" & Join(Application.Index(Evaluate("=IF(ISERROR(MATCH(F2:F463,C2:C463*($A$2:$A$1000=$I$1),0)*($A$2:$A$1000=$I$1)),ROW(F2:F463),0)"), Evaluate("=column(A:QT)"), Evaluate("=column(A:QT)/column(A:QT)")), "#"), "#0", ""), 2), "#")), 1), 1), 1).Value = Application.Index(Worksheets("Sheet1").Columns(6), Application.Transpose(Split(Mid(Replace("#" & Join(Application.Index(Evaluate("=IF(ISERROR(MATCH(F2:F463,C2:C463*($A$2:$A$1000=$I$1),0)*($A$2:$A$1000=$I$1)),ROW(F2:F463),0)"), Evaluate("=column(A:QT)"), Evaluate("=column(A:QT)/column(A:QT)")), "#"), "#0", ""), 2), "#")), 1)
    End Sub
    Attached Files Attached Files
    ….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!!

  8. #448
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,429
    Rep Power
    10
    post for latzer use


    View North from Balcony .. a castle I don’t know the name of on the Horizon, ( the hook is part of the Father in Laws new elevator to lift up shopping etc to the Third floor
    02_BalconyNorthAnotherCastleAndHookFromFatherInLaw sMotorisedLift.jpg : https://imgur.com/ZG6Dmg2

    View South from Balcony – the famous Coburg Veste
    03_BalconySouthVeste.jpg : https://imgur.com/uNnCO8F

    View East from Balcony - Bavarian fairy land
    06_PrettyViewEast.jpg : https://imgur.com/1DzYrL2

    Beer Mugs: I don’t drink much, certainly not at home, and never when building. But with the Father in Law it has become a bit of a tradition .. a German beer or two.
    04_CoburgBalconyBeerMugs.jpg : https://imgur.com/RDXq3HH

    Our old Blue bus hidden in a back lane: View of the Veste from guest room, and at the bottom our old blue VW bus – we have to hide it as it does not fit in too well
    05_GuestRoomCoburgVesteAndBlueVWBus.jpg : https://imgur.com/30B3nkp

    A very bad picture or the Veste at night from the parents in law’s living room … Bavarian “Fairy land” – what a view to have..
    08_VesteAtNight.jpg : https://imgur.com/5HrY1Hy

    Finally, that ugly man spoiling the view again..
    07_UglyManInPicture : https://imgur.com/Eic7NSD


    View North from Balcony .. a castle I don’t know the name of on the Horizon, ( the hook is part of the Father in Laws new elevator to lift up shopping etc to the Third floor
    02_BalconyNorthAnotherCastleAndHookFromFatherInLaw sMotorisedLift.jpg : http://i.imgur.com/ZG6Dmg2.jpg

    View South from Balcony – the famous Coburg Veste
    03_BalconySouthVeste.jpg : http://i.imgur.com/uNnCO8F.jpg

    View East from Balcony - Bavarian fairy land
    06_PrettyViewEast.jpg : http://i.imgur.com/1DzYrL2.jpg

    Beer Mugs: I don’t drink much, certainly not at home, and never when building. But with the Father in Law it has become a bit of a tradition .. a German beer or two.
    04_CoburgBalconyBeerMugs.jpg : http://i.imgur.com/RDXq3HH.jpg

    Our old Blue bus hidden in a back lane: View of the Veste from guest room, and at the bottom our old blue VW bus – we have to hide it as it does not fit in too well
    05_GuestRoomCoburgVesteAndBlueVWBus.jpg : http://i.imgur.com/30B3nkp.jpg

    A very bad picture or the Veste at night from the parents in law’s living room … Bavarian “Fairy land” – what a view to have..
    08_VesteAtNight.jpg : http://i.imgur.com/5HrY1Hy.jpg

    Finally, that ugly man spoiling the view again..
    07_UglyManInPicture : http://i.imgur.com/Eic7NSD.jpg
    ….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!!

  9. #449
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,429
    Rep Power
    10
    In support of these post
    https://eileenslounge.com/viewtopic....281384#p281384
    https://eileenslounge.com/viewtopic....281383#p281383





    Finally, If I use a simple Dictionary way to get your unique names from your column A, then I can incorporate my ideas into a full solution that gets the same results as Hans using your uploaded test data.
    Rem 1 Gets your unique names from column A
    Rem 2 Loops through those unique names and each time in the loop the Function is called to get an array of your missings.


    Code:
    Sub EvaluateRangeFormulaWay()  '   http://www.eileenslounge.com/viewtopic.php?p=281315#p281315
    Rem 0 worksheets info
    Dim Ws1 As Worksheet, Ws2 As Worksheet
     Set Ws1 = ThisWorkbook.Worksheets.Item("Sheet1"): Set Ws2 = ThisWorkbook.Worksheets.Item("Sheet2Alan")
    Dim Em1 As Long: Let Em1 = Ws1.Range("A" & Ws1.Rows.Count & "").End(xlUp).Row
    Dim arrA1() As Variant: Let arrA1() = Ws1.Range("A1:A" & Em1 & "").Value2  '  All names list
    Rem 1
    Dim Dik1 As Object: Set Dik1 = CreateObject("Scripting.Dictionary")
    ' 1b) make list of unique names
    Dim Cnt
        For Cnt = 2 To Em1 ' Looping down all names
         Let Dik1(arrA1(Cnt, 1)) = "This can be anything you like, it don't really matter. What happens here is that we try to put this text in the Item of a dictionary entry that has the key of  the value of    arrA1(Cnt, 1)       If that entry does not exist, then the dictionary is programmed not to error , but instead make ( Add )  an entry with that key value.    For our purposes we don't care what the items are.  But at the end of this loop we will have effectively  Added  a element in the dictionary, one for each of the unique name values.  We can then use the  Keys()  array as a convenient way to get an array of unique names"
        Next Cnt
    Dim arrUnics() As Variant: Let arrUnics() = Dik1.Keys() ' This is an array of our  unique  Names
    Rem 2 Do it
    Dim R3Lne As Long: Let R3Lne = 2    ' This is the next free line in second worksheet
        For Cnt = 0 To UBound(arrUnics()) ' looping through all uniques names
        Dim arrMisins() As Variant: Let arrMisins() = Missings(arrUnics(Cnt))  '## Go to the function that makes an array of the  Missing  dates   based on the  Name value
        Dim NoMisins As Long: Let NoMisins = UBound(arrMisins(), 1)
         Let Ws2.Range("A" & R3Lne & ":A" & R3Lne + (NoMisins - 1) & "").Value = arrUnics(Cnt) ' Put the name in as many cells as we have  missing  dates
         Let Ws2.Range("B" & R3Lne & ":B" & R3Lne + (NoMisins - 1) & "").Value = arrMisins()   ' Put the missing dates in
         Let R3Lne = R3Lne + NoMisins  ' This is the next free line in second worksheet
        Next Cnt
     
     Let Ws2.Range("B2:B" & Ws2.UsedRange.Rows.Count + 1 & "").NumberFormat = "yyyy/mm/dd"
    End Sub
    Function Missings(ByVal Nme As String) As Variant
    Dim arrStrTemp() As String: Let arrStrTemp() = Split(Mid(Replace("#" & Join(Application.Index(Worksheets("Sheet1").Evaluate("=IF(ISERROR(MATCH(F2:F463,C2:C463*($A$2:$A$1000=" & """" & Nme & """" & "),0)*($A$2:$A$1000=" & """" & Nme & """" & ")),ROW(F2:F463),0)"), Evaluate("=column(A:QT)"), Evaluate("=column(A:QT)/column(A:QT)")), "#"), "#0", ""), 2), "#")
    Dim arrTemp() As Variant: Let arrTemp() = Application.Index(Worksheets("Sheet1").Columns(6), Application.Index(arrStrTemp(), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")/row(1:" & UBound(arrStrTemp()) + 1 & ")"), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")")), 1)
     Let Missings = arrTemp()
    End Function
    
    
    
    
    
    
    
    
    Sub TestFunctionMissings()
    Dim arrTemp() As Variant
     Let arrTemp() = Missings("bb")
     ' Columns("T:T").ClearContents  ' Range("T2").Resize(UBound(arrTemp(), 1), 1).ClearContents
     Let Range("T2").Resize(UBound(arrTemp(), 1), 1).Value = arrTemp()
     Let Range("T2").Resize(UBound(arrTemp(), 1), 1).NumberFormat = "yyyy/mm/dd"
    End Sub
    
    Attached Files Attached Files
    ….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!!

  10. #450
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,429
    Rep Power
    10
    I have done another couple of versions, just out of interest.

    I have also adjusted the code to be the same last row, but in these two versions the last row is not hard coded. I am using the last row of data. So that is found dynamically in the usual way.

    Because we use the same last row, I can simplify a few things.

    The difference between the two new versions is that
    _ one uses the conventional Transpose function to do a couple of transposing.
    _ In the other one, the same transposing is done in that strange Index function way that I personally like to do.


    Index Function Way
    Code:
    ' Using the  Index  way for the tranposing
    Sub Pretty3d()  '
    Rem 0 worksheets info
    Dim Ws1 As Worksheet
     Set Ws1 = ThisWorkbook.Worksheets.Item("Sheet1")
    Dim M As Long: Let M = Ws1.Range("A" & Ws1.Rows.Count & "").End(xlUp).Row
    
    
    Dim arrTemp() As Variant
    Rem  To get the results in  column  T  ( same as Yassers or Hans Results
     ' Ths first forumula gives me all the matches for F in the C ( helper column )  or error for no match
     Let arrTemp() = Evaluate("=If({1},MATCH(F2:F" & M & ",Int(B2:B" & M & "),0))")   '   If({1},____)    may not be needed for Excel 2016 and higher   The first formula does the main work
     ' The multiplication by $A$2:$A$1000=$I$1 limits the range used by effectively making 0 check dates outside or range of interest
     Let arrTemp() = Evaluate("=IF({1},MATCH(F2:F" & M & ",Int(B2:B" & M & ")*($A$2:$A$1000=$I$1),0))")   '  $A$2:$A$1000=$I$1 gives us an array full of  Falses and Trues , which Excel will interpret mathematically as 0 or 1   This has the effect of giving us a 0 multiplyer on numbers outside our range of interst, so in total a 0 for outside our range of interest.   Our range of interest gets a 1 multiplier so has therefore no change and we can find those numbers whereas we wont find a 0, well actually we will find a zero if the range to search for has a zero as it does further down, so we take care of that in the next line
     ' The above formula has one problem with the supplied data in that empty cells are seen in this formula as 0 which gives a match
     Let arrTemp() = Evaluate("=IF(F2:F" & M & "=0,0,MATCH(F2:F" & M & ",C2:C" & M & "*(A2:A" & M & "=I1),0))")   '   In looking in the range to find a match in ( the range to be searched we have all 0s outside the range caused by the previous $A$2:$A$1000=$I$1  So the first of these 0s will be seen as the match cell for all cells in  F  that are empty.  So i take care here of the situation where an empty cell in  F  is by  giving a  0  output   So far two things retrn me a zero.   You often find in formula building that the coercing  If({1},___) suddenly is not needed. Her we find that the newly used here  IF(F2:F463=0,0,___)  is doing the required co oecing
     ' we will now do a simple  If(ISERROR( ) , Row( ) , 0 ) on the above . This will give us a row indicie for the missing data,  and  a  0  for the found data
     Let arrTemp() = Evaluate("=IF(ISERROR(MATCH(F2:F" & M & ",Int(B2:B" & M & ")*(A2:A" & M & "=I1),0)*(A2:A" & M & "=I1)),ROW(F2:F" & M & "),0)")
     ' At this point we have wanted data or zeros. I want to conveniently use some VB string fuction whuch annoyingly onl work on 1 D arrays, so we convert it by a transpose in the next code line
     Let arrTemp() = Application.Index(arrTemp(), Evaluate("=column(A:" & CL(M - 1) & ")"), Evaluate("=column(A:" & CL(M - 1) & ")/column(A:" & CL(M - 1) & ")"))
     ' Or
    ' Let arrTemp() = Application.Transpose(arrTemp())
     
     Let arrTemp() = Application.Index(Evaluate("=IF(ISERROR(MATCH(F2:F" & M & ",Int(B2:B" & M & ")*(A2:A" & M & "=I1),0)*(A2:A" & M & "=I1)),ROW(F2:F" & M & "),0)"), Evaluate("=column(A:" & CL(M - 1) & ")"), Evaluate("=column(A:" & CL(M - 1) & ")/column(A:" & CL(M - 1) & ")"))
     
     ' The next few lines get rid of the  0s   ( 2 lines commented out to prevent the shortened line messing up )
    Dim StrTemp As String: Let StrTemp = "#" & Join(arrTemp(), "#") ' Convert the array to a string with a  #  in between each data.  The extra # allows us to remove all  0  entries via removing all  #0  Without this we might get one left at the start
    ' Let StrTemp = Replace(StrTemp, "#0", "", 1, -1, vbBinaryCompare) ' This effectiveely removes the  0s   data ( and its seperator )
    ' Let StrTemp = Mid(StrTemp, 2) '  Because I omit the third optional ( length ) argument I get all the remaing string after the first one. This effectively takes off the extra  #  which I don't need
    Dim arrStrTemp() As String: Let arrStrTemp() = Split(StrTemp, "#", -1, vbBinaryCompare) ' remake the array
    ' Or ,
     Let arrStrTemp() = Split(Mid(Replace("#" & Join(Application.Index(Evaluate("=IF(ISERROR(MATCH(F2:F" & M & ",Int(B2:B" & M & ")*(A2:A" & M & "=I1),0)*(A2:A" & M & "=I1)),ROW(F2:F" & M & "),0)"), Evaluate("=column(A:" & CL(M - 1) & ")"), Evaluate("=column(A:" & CL(M - 1) & ")/column(A:" & CL(M - 1) & ")")), "#"), "#0", ""), 2), "#")
     ' We need a "vertical" array for output, so we  transpose
     Let arrTemp() = Application.Index(arrStrTemp(), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")/row(1:" & UBound(arrStrTemp()) + 1 & ")"), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")"))
     
     Let arrTemp() = Application.Index(Worksheets("Sheet1").Columns(6), arrTemp(), 1) ' finally we want the  dates  ( so far we have the row indicies obtained from  Match   Note. this formula has the problem that we get the results  a row out of step... Its actually very convenient because if i use  Cells typically, here a column  then I have a nice solution
    ' Or
     Let arrTemp() = Application.Index(Worksheets("Sheet1").Columns(6), Application.Index(arrStrTemp(), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")/row(1:" & UBound(arrStrTemp()) + 1 & ")"), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")")), 1) ' finally we want the  dates  ( so far we have the row indicies obtained from  Match   Note. this formula has the problem that we get the results  a row out of step... Its actually very convenient because if i use  Cells typically, here a column  then I have a nice solution
    ' or
     Let Range("T2").Resize(UBound(arrTemp(), 1), 1).Value = arrTemp()
     Let Range("T2").Resize(UBound(Application.Index(Worksheets("Sheet1").Columns(6), Application.Index(arrStrTemp(), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")/row(1:" & UBound(arrStrTemp()) + 1 & ")"), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")")), 1), 1), 1).Value = Application.Index(Worksheets("Sheet1").Columns(6), Application.Index(arrStrTemp(), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")/row(1:" & UBound(arrStrTemp()) + 1 & ")"), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")")), 1)
     
     
     Let Range("T2").Resize(UBound(arrTemp(), 1), 1).NumberFormat = "yyyy/mm/dd" '  from macro recorder .NumberFormat = "[$-1010000]yyyy/mm/dd,@"
    Stop
    ' Range("T2").Resize(UBound(arrTemp(), 1), 1).ClearContents
      
    End Sub
    Sub ShortPretty3d()
    Dim M As Long: Let M = Worksheets("Sheet1").Range("A" & Worksheets("Sheet1").Rows.Count & "").End(xlUp).Row
    Dim arrStrTemp() As String: Let arrStrTemp() = Split(Mid(Replace("#" & Join(Application.Index(Evaluate("=IF(ISERROR(MATCH(F2:F" & M & ",Int(B2:B" & M & ")*(A2:A" & M & "=I1),0)*(A2:A" & M & "=I1)),ROW(F2:F" & M & "),0)"), Evaluate("=column(A:" & CL(M - 1) & ")"), Evaluate("=column(A:" & CL(M - 1) & ")/column(A:" & CL(M - 1) & ")")), "#"), "#0", ""), 2), "#")
     Let Range("T2").Resize(UBound(Application.Index(Worksheets("Sheet1").Columns(6), Application.Index(arrStrTemp(), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")/row(1:" & UBound(arrStrTemp()) + 1 & ")"), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")")), 1), 1), 1).Value = Application.Index(Worksheets("Sheet1").Columns(6), Application.Index(arrStrTemp(), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")/row(1:" & UBound(arrStrTemp()) + 1 & ")"), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")")), 1)
    End Sub
    Function ShortPretty3dFunction(ByVal Nme As String) As Variant
    Dim M As Long: Let M = Worksheets("Sheet1").Range("A" & Worksheets("Sheet1").Rows.Count & "").End(xlUp).Row
    Dim arrStrTemp() As String: Let arrStrTemp() = Split(Mid(Replace("#" & Join(Application.Index(Evaluate("=IF(ISERROR(MATCH(F2:F" & M & ",Int(B2:B" & M & ")*(A2:A" & M & "=" & """" & Nme & """" & "),0)*(A2:A" & M & "=" & """" & Nme & """" & ")),ROW(F2:F" & M & "),0)"), Evaluate("=column(A:" & CL(M - 1) & ")"), Evaluate("=column(A:" & CL(M - 1) & ")/column(A:" & CL(M - 1) & ")")), "#"), "#0", ""), 2), "#")
     Let ShortPretty3dFunction = Application.Index(Worksheets("Sheet1").Columns(6), Application.Index(arrStrTemp(), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")/row(1:" & UBound(arrStrTemp()) + 1 & ")"), Evaluate("=row(1:" & UBound(arrStrTemp()) + 1 & ")")), 1)
    End Function
    Sub TestShortPretty3dFunction()
    Dim arrTemp() As Variant
     Let arrTemp() = ShortPretty3dFunction("aa")
     Range("T2").Resize(UBound(arrTemp(), 1), 1).ClearContents
     Let Range("T2").Resize(UBound(arrTemp(), 1), 1).Value = arrTemp()
     Let Range("T2").Resize(UBound(arrTemp(), 1), 1).NumberFormat = "yyyy/mm/dd"
    End Sub















    see next post
    Transpose Function Way
    Attached Files Attached Files
    ….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. Replies: 185
    Last Post: 05-22-2024, 10:02 PM
  2. Replies: 603
    Last Post: 05-20-2024, 03:31 PM
  3. Replies: 293
    Last Post: 09-24-2020, 01:53 AM
  4. Appendix Thread. Diet Protokol Coding Adaptions
    By DocAElstein in forum Test Area
    Replies: 6
    Last Post: 09-05-2019, 10:45 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
  •