# VBA Loop Lookup of every nth (eg. every 3rd) match of an item



## Oraekene (Nov 24, 2022)

Hi. Good day. Grateful for all the help i've received on this site so far. Here again cap in hand seeking help.

I would like a vb script to loop through a range of values and find every nth eg. Every 3rd occurence of that value and copy and paste the single row of values in the next  empty row in another range

Eg. I have customer data of 50 purchases made by 4 customers eg. A B C & D. Each purchase is a row of values showing date of purchase, item of purchase, price etc. I'd like to find every 3rd purchase A made (so her 3rd, 6th, 9th, 12th etc) and copy the row of data (date, item etc) to another range, then repeat for B, then repeat for C and D.

Would be grateful for any help on this. Attached is the sample sheet Sample Sheet


----------



## Trebor76 (Nov 26, 2022)

Hi Oraekene,

My following macro produces an extra record for "martin" from Row 38 but I think it's oversight on your side not the macro itself:


```
Option Explicit
Sub Macro1()

    Dim wsSrc As Worksheet
    Dim lngSrcRow As Long, lngRowTo As Long, i As Long, j As Long
    Dim dictNames As Object
    Dim rngCell As Range, rngRqdData As Range
    Dim strName As String
    
    Application.ScreenUpdating = False
    
    Set wsSrc = ThisWorkbook.Sheets("Sheet1") 'Sheet name containing the data. Change to suit.
    lngRowTo = wsSrc.Range("A:E").Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row + 1
    Set dictNames = CreateObject("Scripting.Dictionary")
    
    On Error Resume Next
        wsSrc.ShowAllData
    On Error GoTo 0
    
    For lngSrcRow = 2 To lngRowTo
        strName = wsSrc.Range("A" & lngSrcRow)
        If Not dictNames.Exists(strName) And Application.WorksheetFunction.CountIf(wsSrc.Range("A2:A" & lngRowTo), strName) >= 3 Then
            i = i + 1: j = 0
            dictNames.Add strName, i
            For Each rngCell In wsSrc.Range("A2:A" & lngRowTo)
                If strName = CStr(rngCell) Then
                    j = j + 1
                    If (j Mod 3) = 0 Then
                        If rngRqdData Is Nothing Then
                            Set rngRqdData = wsSrc.Range("A" & rngCell.Row & ":E" & rngCell.Row)
                        Else
                            Set rngRqdData = Union(rngRqdData, wsSrc.Range("A" & rngCell.Row & ":E" & rngCell.Row))
                        End If
                    End If
                End If
            Next rngCell
        End If
    Next lngSrcRow
    
    rngRqdData.Copy Destination:=wsSrc.Range("M2")
    
    Application.ScreenUpdating = True

End Sub
```

Regards,

Robert


----------



## Peter_SSs (Nov 27, 2022)

Oraekene said:


> I'd like to find every 3rd purchase A made (so her 3rd, 6th, 9th, 12th etc) and copy the row of data (date, item etc) to another range, then repeat for B, then repeat for C and D.


If your sample workbook contains your expected results, then you haven't processed the data in the order mentioned above. Here is a non-looping option to produce the sample results (with adjustment already mentioned by Robert). If you want the results grouped by customer (sorted alphabetically) then uncomment the Sort line near the end of the code.


```
Sub EveryNth()
  Dim cols As Long
  Dim rDel As Range
  
  Const N As Long = 3 'That is, keep every 3rd
  
  Application.ScreenUpdating = False
  Range("A1").CurrentRegion.Copy Destination:=Range("M1")
  With Range("M1").CurrentRegion
    cols = .Columns.Count
    With .Resize(, cols + 1)
      .Columns(cols + 1).FormulaR1C1 = Replace("=mod(countif(R1C[-#]:RC[-#],RC[-#])," & N & ")", "#", cols)
      .AutoFilter Field:=cols + 1, Criteria1:=">0"
      Set rDel = .Offset(1).SpecialCells(xlVisible)
      ActiveSheet.AutoFilterMode = False
      rDel.Delete Shift:=xlUp
      .Columns(cols + 1).ClearContents
'      .Sort Key1:=.Columns(1), Order1:=xlAscending, Header:=xlYes
    End With
  End With
  Application.ScreenUpdating = True
End Sub
```


----------



## Oraekene (Nov 27, 2022)

Trebor76 said:


> Hi Oraekene,
> 
> My following macro produces an extra record for "martin" from Row 38 but I think it's oversight on your side not the macro itself:
> 
> ...


Thank you for this! And happy thanksgiving! Hope it was fun. Nigerian here so we don't celebrate it, but i know its a big big deal so hope the weekend has been fun. Will try this out and get back to you


----------



## Oraekene (Nov 27, 2022)

Peter_SSs said:


> If your sample workbook contains your expected results, then you haven't processed the data in the order mentioned above. Here is a non-looping option to produce the sample results (with adjustment already mentioned by Robert). If you want the results grouped by customer (sorted alphabetically) then uncomment the Sort line near the end of the code.
> 
> 
> ```
> ...


You always come through! Thank you! Don't know if you're American but if you are Happy Thanksgiving! Hope the weekend has been fun

Yes yes yes you are right, its not in the order as i initially explained it, grouped by customer. The way i laid it in the samples sheet is exactly how i want it, and the reason is i'd like to sort all purchases by date and time from the earliest to the latest. Thank you for noticing the oversight. I'll try this out and get back to you on this


----------



## Peter_SSs (Nov 27, 2022)

You're welcome.



Oraekene said:


> Don't know if you're American


I'm not. If you hover over my avatar or user name on the left of this window you can see.


----------



## Oraekene (Nov 27, 2022)

They both work excellently well! Thank you! I can only select one right answer so i'll choose it arbitrarily but they both work perfectly well, thank you!


----------



## Trebor76 (Nov 27, 2022)

> They both work excellently well! Thank you! I can only select one right answer so i'll choose it arbitrarily but they both work perfectly well, thank you!



I see you've marked my suggested macro as the solution.  I personally would have chosen Peter's as his method does not loop and will therefore be much faster on larger datasets


----------



## Oraekene (Dec 1, 2022)

Trebor76 said:


> I see you've marked my suggested macro as the solution.  I personally would have chosen Peter's as his method does not loop and will therefore be much faster on larger datasets


I did because i had no idea how to decide and yours was first so i just went for it. But yeah you're very right, i'll mark his now


----------



## Oraekene (Dec 8, 2022)

Hi. I'd like some help. Went back and realised i need to change the filter criteria. Its still every 3rd mention but now it would be based on two criteria: the name of the item and a 3rd unique mention from a account. I'll drop an example below to explain

ACCOUNT - PROJECT - TIMEDATE - Rate (acct) - Rate(proj) - Rate(mention from that account)
10xe001  -  jagudam - 12/03/22 - A - 1 - i
10xe001  -  jagudam - 12/03/22 - A - 1 - ii
10xe002  -  mandela - 12/03/22 - B - 2 - i
10xe002  -  nsobu - 13/0/22 - B - 3 - i
10xe001  -  mandela - 13/03/22 - A - 2 - i
10xe003  -  mandela - 14/03/22 - C - 2 - i 🍩
10xe004  -  mandela - 14/03/22 - D - 1 - i
10xe002  -  caricature - 14/03/22 - B - 4 - i
10xe002  -  nsobu - 14/03/22 - B - 3 - ii
10xe002  -  deeper life - 16/03/22 - B - 5 - i
10xe001  -  deeper life - 17/03/22 - A - 5 - i
10xe001  -  jagudam - 17/03/22 - A - 1 - iii
10xe004  -  jagudam - 18/03/22 - D - 1 - ii
10xe004 -  jagudam - 18/03/22 - D - 1 - iii
10xe005  -  jagudam - 18/03/22 - E - 1 - i📍
10xe002  -  jagudam - 18/03/22 - B - 1 - i
10xe003  -  mandela - 18/03/22 - C - 2 - ii
10xe003  -  nsobu - 18/03/22 - C - 3 - i
10xe003  -  mandela - 18/03/22 - C - 2 - iii
10xe003  -  mandela - 18/03/22 - C - 2 - iv
10xe005  -  mandela - 18/03/22 - E - 2 - i
10xe003  -  caricature - 19/03/22 - C - 4 - i
10xe001  -  nsobu - 19/03/22 - A - 3 - i🎄
10xe001  -  deeper life - 19/03/22 - A - 5 - ii
10xe004  -  deeper life - 20/03/22 - D - 5 - i😁
10xe004 -  jagudam - 22/03/22 - D - 1 - iii
10xe005  -  jagudam - 22/03/22 - E - 1 - ii📍
10xe003  -  jagudam - 22/03/22 - C - 1 - i
10xe004 -  jagudam - 23/03/22 - D - 1 - iv
10xe002 -  jagudam - 24/03/22 - B - 1 - ii📍
10xe001  -  jagudam - 24/03/22 - A - 1 - iv
10xe001  -  mandela - 25/03/22 - A - 2 - ii🍩
10xe001  -  nsobu - 25/03/22 - A - 3 - ii
10xe001  -  mandela - 25/03/22 - A - 2 - iii
10xe002 -  mandela - 25/03/22 - B - 2 - i
10xe002  -  mandela - 25/03/22 - B - 2 - ii
10xe004  -  caricature - 25/03/22 - D - 4 - i🏫
10xe005  -  nsobu - 25/03/22 - E - 3 - i
10xe005  -  deeper life - 25/03/22 - E - 5 - i
10xe005  -  deeper life - 26/03/22 - E - 5 - ii
10xe005 -  jagudam - 27/03/22 - E - 1 - iii
10xe001  -  jagudam - 27/03/22 - A - 1 - v
10xe005  -  jagudam - 28/03/22 - E - 1 - iv

The emojis indicate a highlighted result, each emoji type for a different project. Here is the key 

Jagudam - 1 - 📍
Mandela - 2 - 🍩
Nsobu - 3 - 🎄
Caricature - 4 - 🏫
Deeper life - 5 - 😁

*C-2-i where the 'C' are the account numbers, '2' are the projects, and 'i' is the sequence of times the same account appears with the same project

Above, when a project appears with a third unique account, it is selected. So for example the first selection: account 001 appears with mandela, then account 002 then when account 003 appears with mandela, that entry is selected, and the filter resets itself and starts acounting again. With Jagudam for eg, account 001 appeared with it multiple time, but it wasn't until the third unique account, account 005, that the selection was made

Can this be achieved?


----------



## Oraekene (Nov 24, 2022)

Hi. Good day. Grateful for all the help i've received on this site so far. Here again cap in hand seeking help.

I would like a vb script to loop through a range of values and find every nth eg. Every 3rd occurence of that value and copy and paste the single row of values in the next  empty row in another range

Eg. I have customer data of 50 purchases made by 4 customers eg. A B C & D. Each purchase is a row of values showing date of purchase, item of purchase, price etc. I'd like to find every 3rd purchase A made (so her 3rd, 6th, 9th, 12th etc) and copy the row of data (date, item etc) to another range, then repeat for B, then repeat for C and D.

Would be grateful for any help on this. Attached is the sample sheet Sample Sheet


----------



## Oraekene (Dec 8, 2022)

@Peter_SSs @Trebor76 please help. Its just a modification of the original request which is why i didn't post it in a new thread. Sample sheet here. Please help


----------



## Peter_SSs (Dec 10, 2022)

Oraekene said:


> Its just a modification of the original request


I don't understand what is required this time. Can you spell out in detail how we would decide which rows from that sample sheet get transferred to columns J to O?
That is, exactly how did you manually decide which rows to bold in columns A:F?


----------



## Oraekene (Dec 12, 2022)

Peter_SSs said:


> I don't understand what is required this time. Can you spell out in detail how we would decide which rows from that sample sheet get transferred to columns J to O?
> That is, exactly how did you manually decide which rows to bold in columns A:F?


Thank you for the response and apologies for my late reply. Here is the explanation

There are basically 2 criteria: the Account Numbers (the first column with the 10xe001, 10xe002 type numbers) and the project names (the second column with the Jaguda, Nsobu, mandela names). The whole range is sorted by time from the earliest to the latest time

What i hope to achieve is for ever project (eg. Mandela), i'd like to find the third unique wallet (eg. 10xe003) linked to that project. So for example Mandela might have rows with Mandela-10xe001, Mandela-10xe001, Mandela-10xe002, Mandela-10xe001, Mandela-10xe002,Mandela-10xe003. The row that would be selected would be the Mandela-10xe003 because that would be the row with the third unique wallet - 10xe003 - for the project named Mandela. 

I don't know if this helps, i hope it does


----------



## Peter_SSs (Dec 12, 2022)

Thanks for the clarification. At this point I don't see an obvious solution for your excel version.


----------



## Oraekene (Dec 12, 2022)

Peter_SSs said:


> Thanks for the clarification. At this point I don't see an obvious solution for your excel version.


Oh no problem. Wanted to ask if there would be possible solutions on later excel versions?


----------



## Peter_SSs (Dec 13, 2022)

Oraekene said:


> Wanted to ask if there would be possible solutions on later excel versions?


Unfortunately your description in post 13 about how to decide which *rows* to return only covered *one *row, not how to also get subsequent rows. The best guess that I can give, which does not not match your given expected results**, is ..

** From what I understand, row 21 should be in the results since that row contains the 3rd unique value for mandela since the previously recorded mandela row (row 6)

Oraekene kantakura.xlsxABCDEFGJKLMNO110xe001  jagudam 12/03/2022 A 1 i10xe003  mandela 14/03/2022 C 2 i 210xe001  jagudam 12/03/2022 A 1 ii10xe005  jagudam 18/03/2022 E 1 i310xe002  mandela 12/03/2022 B 2 iFALSE10xe005  mandela 18/03/2022 E 2 i410xe002  nsobu  3/12/2022  B 3 iFALSE10xe001  nsobu 19/03/2022 A 3 i510xe001  mandela 13/03/2022 A 2 iFALSE10xe004  deeper life 20/03/2022 D 5 i610xe003  mandela 14/03/2022 C 2 i TRUE10xe005  jagudam 22/03/2022 E 1 ii710xe004  mandela 14/03/2022 D 1 iFALSE10xe002  jagudam 24/03/2022 B 1 ii810xe002  caricature 14/03/2022 B 4 iFALSE10xe004  caricature 25/03/2022 D 4 i910xe002  nsobu 14/03/2022 B 3 iiFALSE1010xe002  deeper life 16/03/2022 B 5 iFALSE1110xe001  deeper life 17/03/2022 A 5 iFALSE1210xe001  jagudam 17/03/2022 A 1 iiiFALSE1310xe004  jagudam 18/03/2022 D 1 iiFALSE1410xe004  jagudam 18/03/2022 D 1 iiiFALSE1510xe005  jagudam 18/03/2022 E 1 iTRUE1610xe002  jagudam 18/03/2022 B 1 iFALSE1710xe003  mandela 18/03/2022 C 2 iiFALSE1810xe003  nsobu 18/03/2022 C 3 iFALSE1910xe003  mandela 18/03/2022 C 2 iiiFALSE2010xe003  mandela 18/03/2022 C 2 ivFALSE2110xe005  mandela 18/03/2022 E 2 iTRUE2210xe003  caricature 19/03/2022 C 4 iFALSE2310xe001  nsobu 19/03/2022 A 3 iTRUE2410xe001  deeper life 19/03/2022 A 5 iiFALSE2510xe004  deeper life 20/03/2022 D 5 iTRUE2610xe004  jagudam 22/03/2022 D 1 iiiFALSE2710xe005  jagudam 22/03/2022 E 1 iiTRUE2810xe003  jagudam 22/03/2022 C 1 iFALSE2910xe004  jagudam 23/03/2022 D 1 ivFALSE3010xe002  jagudam 24/03/2022 B 1 iiTRUE3110xe001  jagudam 24/03/2022 A 1 ivFALSE3210xe001  mandela 25/03/2022 A 2 iiFALSE3310xe001  nsobu 25/03/2022 A 3 iiFALSE3410xe001  mandela 25/03/2022 A 2 iiiFALSE3510xe002  mandela 25/03/2022 B 2 iFALSE3610xe002  mandela 25/03/2022 B 2 iiFALSE3710xe004  caricature 25/03/2022 D 4 iTRUE3810xe005  nsobu 25/03/2022 E 3 iFALSE3910xe005  deeper life 25/03/2022 E 5 iFALSE4010xe005  deeper life 26/03/2022 E 5 iiFALSE4110xe005  jagudam 27/03/2022 E 1 iiiFALSE4210xe001  jagudam 27/03/2022 A 1 vFALSE4310xe005  jagudam 28/03/2022 E 1 ivFALSESheet1Cell FormulasRangeFormulaJ1:O8J1=FILTER(A1:F43,G1:G43)G3:G43G3=LET(fr,IFNA(XMATCH(B3&TRUE,B$1:B2&G$1:G2,,-1),0)+1,MOD(ROWS(UNIQUE(FILTER(INDEX(A$1:A3,fr):A3,INDEX(B$1:B3,fr):B3=B3))),3)=0)Dynamic array formulas.


----------



## Oraekene (Dec 13, 2022)

Peter_SSs said:


> Unfortunately your description in post 13 about how to decide which *rows* to return only covered *one *row, not how to also get subsequent rows. The best guess that I can give, which does not not match your given expected results**, is ..
> 
> ** From what I understand, row 21 should be in the results since that row contains the 3rd unique value for mandela since the previously recorded mandela row (row 6)
> 
> Oraekene kantakura.xlsxABCDEFGJKLMNO110xe001  jagudam 12/03/2022 A 1 i10xe003  mandela 14/03/2022 C 2 i 210xe001  jagudam 12/03/2022 A 1 ii10xe005  jagudam 18/03/2022 E 1 i310xe002  mandela 12/03/2022 B 2 iFALSE10xe005  mandela 18/03/2022 E 2 i410xe002  nsobu  3/12/2022  B 3 iFALSE10xe001  nsobu 19/03/2022 A 3 i510xe001  mandela 13/03/2022 A 2 iFALSE10xe004  deeper life 20/03/2022 D 5 i610xe003  mandela 14/03/2022 C 2 i TRUE10xe005  jagudam 22/03/2022 E 1 ii710xe004  mandela 14/03/2022 D 1 iFALSE10xe002  jagudam 24/03/2022 B 1 ii810xe002  caricature 14/03/2022 B 4 iFALSE10xe004  caricature 25/03/2022 D 4 i910xe002  nsobu 14/03/2022 B 3 iiFALSE1010xe002  deeper life 16/03/2022 B 5 iFALSE1110xe001  deeper life 17/03/2022 A 5 iFALSE1210xe001  jagudam 17/03/2022 A 1 iiiFALSE1310xe004  jagudam 18/03/2022 D 1 iiFALSE1410xe004  jagudam 18/03/2022 D 1 iiiFALSE1510xe005  jagudam 18/03/2022 E 1 iTRUE1610xe002  jagudam 18/03/2022 B 1 iFALSE1710xe003  mandela 18/03/2022 C 2 iiFALSE1810xe003  nsobu 18/03/2022 C 3 iFALSE1910xe003  mandela 18/03/2022 C 2 iiiFALSE2010xe003  mandela 18/03/2022 C 2 ivFALSE2110xe005  mandela 18/03/2022 E 2 iTRUE2210xe003  caricature 19/03/2022 C 4 iFALSE2310xe001  nsobu 19/03/2022 A 3 iTRUE2410xe001  deeper life 19/03/2022 A 5 iiFALSE2510xe004  deeper life 20/03/2022 D 5 iTRUE2610xe004  jagudam 22/03/2022 D 1 iiiFALSE2710xe005  jagudam 22/03/2022 E 1 iiTRUE2810xe003  jagudam 22/03/2022 C 1 iFALSE2910xe004  jagudam 23/03/2022 D 1 ivFALSE3010xe002  jagudam 24/03/2022 B 1 iiTRUE3110xe001  jagudam 24/03/2022 A 1 ivFALSE3210xe001  mandela 25/03/2022 A 2 iiFALSE3310xe001  nsobu 25/03/2022 A 3 iiFALSE3410xe001  mandela 25/03/2022 A 2 iiiFALSE3510xe002  mandela 25/03/2022 B 2 iFALSE3610xe002  mandela 25/03/2022 B 2 iiFALSE3710xe004  caricature 25/03/2022 D 4 iTRUE3810xe005  nsobu 25/03/2022 E 3 iFALSE3910xe005  deeper life 25/03/2022 E 5 iFALSE4010xe005  deeper life 26/03/2022 E 5 iiFALSE4110xe005  jagudam 27/03/2022 E 1 iiiFALSE4210xe001  jagudam 27/03/2022 A 1 vFALSE4310xe005  jagudam 28/03/2022 E 1 ivFALSESheet1Cell FormulasRangeFormulaJ1:O8J1=FILTER(A1:F43,G1:G43)G3:G43G3=LET(fr,IFNA(XMATCH(B3&TRUE,B$1:B2&G$1:G2,,-1),0)+1,MOD(ROWS(UNIQUE(FILTER(INDEX(A$1:A3,fr):A3,INDEX(B$1:B3,fr):B3=B3))),3)=0)Dynamic array formulas.


Yes yes yes you are right! It was my error. For mandela Row 21 should be the next after row 6, you've very correct. I made an error on my part


----------



## Peter_SSs (Dec 13, 2022)

Glad to help.


----------



## Oraekene (Dec 13, 2022)

Peter_SSs said:


> Glad to help.


Thank you so much for this. How do i use this in vba? Do i use Range.Formula? If so, can i make the range dynamic?


----------



## Peter_SSs (Dec 14, 2022)

Oraekene said:


> How do i use this in vba?


Try this with a copy of your workbook.


```
Sub Every_Nth()
  Dim d As Object
  Dim a As Variant, b As Variant
  Dim i As Long, j As Long, k As Long, uba2 As Long
  
  Const N As Long = 3 '<- Edit to suit. This is for every 3rd one
  
  Set d = CreateObject("Scripting.Dictionary")
  a = Range("A1", Range("F" & Rows.Count).End(xlUp)).Value
  uba2 = UBound(a, 2)
  ReDim b(1 To UBound(a), 1 To uba2)
  For i = 1 To UBound(a)
    If InStr(1, d(a(i, 2)) & "|", "|" & a(i, 1) & "|") = 0 Then
      If UBound(Split(d(a(i, 2)), "|")) = N - 1 Then
        k = k + 1
        For j = 1 To uba2
          b(k, j) = a(i, j)
        Next j
        d.Remove a(i, 2)
      Else
        d(a(i, 2)) = d(a(i, 2)) & "|" & a(i, 1)
      End If
    End If
  Next i
  If k > 0 Then
    With Range("J1").Resize(k, uba2)
      .Value = b
      .Columns.AutoFit
    End With
  End If
End Sub
```


----------



## Oraekene (Nov 24, 2022)

Hi. Good day. Grateful for all the help i've received on this site so far. Here again cap in hand seeking help.

I would like a vb script to loop through a range of values and find every nth eg. Every 3rd occurence of that value and copy and paste the single row of values in the next  empty row in another range

Eg. I have customer data of 50 purchases made by 4 customers eg. A B C & D. Each purchase is a row of values showing date of purchase, item of purchase, price etc. I'd like to find every 3rd purchase A made (so her 3rd, 6th, 9th, 12th etc) and copy the row of data (date, item etc) to another range, then repeat for B, then repeat for C and D.

Would be grateful for any help on this. Attached is the sample sheet Sample Sheet


----------



## Oraekene (Dec 14, 2022)

Peter_SSs said:


> Glad to help.


Thank you so much for this. How do i use this in vba? Do i use worksheet.


Peter_SSs said:


> Try this with a copy of your workbook.
> 
> 
> ```
> ...


Thank you so much for this. I'l guess this would work in 2016 and on. I'd find a copy or try to use 365 online and try this code and give feedback. Thank you so much for this


----------



## Peter_SSs (Dec 14, 2022)

Oraekene said:


> I'l guess this would work in 2016 and on.


Yes, but your profile says Excel 2013 though it will run in that version too. Does your profile need updating?



Oraekene said:


> How do i use this in vba?


To implement ..
1. With your workbook active press Alt+F11 to bring up the vba window.
2. In the Visual Basic window use the menu to Insert|Module
3. Copy and Paste the code into the main right hand pane that opens at step 2.
4. Close the Visual Basic window.
5. Press Alt+F8 to bring up the Macro dialog
6. Select the macro & click ‘Run’
7. Your workbook will need to be saved as a macro-enabled workbook (*.xlsm)


----------



## Oraekene (Dec 15, 2022)

Peter_SSs said:


> Yes, but your profile says Excel 2013 though it will run in that version too. Does your profile need updating?


Oh no, i still use 2013, its because earlier you'd said you couldn't find any solution at the time for my version for that particular version, so i thought this vba code was a solution that could only work in newer excel versions. So this script would work in 2013? So so grateful!


----------



## Oraekene (Dec 15, 2022)

Peter_SSs said:


> To implement ..


Oh i know how to add vba scripts to new macros, i was referring to the insheet formula you'd written earlier, before the vba. I was asking how to use that formula directly in the vba environment, whether by calling it via worksheet function or via formula. But then you wrote a perfect vba script after so it would no longer be necessary to need to call the initial formula in the vba. Again i am very grateful for this help, thank you


----------



## Peter_SSs (Dec 15, 2022)

Sorry about the confusion. Glad we got there in the end.


----------



## Oraekene (Dec 17, 2022)

Peter_SSs said:


> Sorry about the confusion. Glad we got there in the end.


I thought i'd be able to do this myself, on the surface seemed simple enough, but once again struggled with this and i need help. Again😭. When i'm done with this project, i'll sit down and do an advanced VBA course to really understand how it works. VBA can be really confusing. Here's the link to the thread Thread 'Loop through subset of worksheets' Loop through subset of worksheets


----------

