Hi guys,
Think this is a relatively simple fix, but have not come across the solution online yet, so apologies if I have missed something obvious!
I am looking at labeling each variable in a loop.
So we have a very basic table, such as :
<code style="font-family: monospace, monospace; margin: 0px 2px; border: 0px; border-radius: 2px; word-break: normal; display: block; font-size: 1em; line-height: 1.42857142857143em; padding: 0px !important; background-color: transparent;"> A B C (just uses a Countif formula in here fyi)
London London1
London London2
London London3
</code>With this VBA code for it:
<code style="font-family: monospace, monospace; margin: 0px 2px; border: 0px; border-radius: 2px; word-break: normal; display: block; font-size: 1em; line-height: 1.42857142857143em; padding: 0px !important; background-color: transparent;">Sub TEST()
LDN_Count= Application.WorksheetFunction.CountIf(Sheets("Sheet1").Range("B1:B10"), "London")
Dim i As Integer
For i = 1 To LDN_Count
"LDN_Locations_"&i = Application.WorksheetFunction.Match("London" & i, Sheets("Sheet1").Range("C1:C10"), 0)
Next i
End Sub
</code>The incorrect part is "LDN_Locations_"&i, but do not know how to label this without generating an error so that I can have a list of locations, I.e. LDN_Location_1 = 2, LDN_Location_2 = 4, LDN_Location = 7... So that I can use them later on in the code.
Any help much appreciated!! Thanks!
Think this is a relatively simple fix, but have not come across the solution online yet, so apologies if I have missed something obvious!
I am looking at labeling each variable in a loop.
So we have a very basic table, such as :
<code style="font-family: monospace, monospace; margin: 0px 2px; border: 0px; border-radius: 2px; word-break: normal; display: block; font-size: 1em; line-height: 1.42857142857143em; padding: 0px !important; background-color: transparent;"> A B C (just uses a Countif formula in here fyi)
London London1
London London2
London London3
</code>With this VBA code for it:
<code style="font-family: monospace, monospace; margin: 0px 2px; border: 0px; border-radius: 2px; word-break: normal; display: block; font-size: 1em; line-height: 1.42857142857143em; padding: 0px !important; background-color: transparent;">Sub TEST()
LDN_Count= Application.WorksheetFunction.CountIf(Sheets("Sheet1").Range("B1:B10"), "London")
Dim i As Integer
For i = 1 To LDN_Count
"LDN_Locations_"&i = Application.WorksheetFunction.Match("London" & i, Sheets("Sheet1").Range("C1:C10"), 0)
Next i
End Sub
</code>The incorrect part is "LDN_Locations_"&i, but do not know how to label this without generating an error so that I can have a list of locations, I.e. LDN_Location_1 = 2, LDN_Location_2 = 4, LDN_Location = 7... So that I can use them later on in the code.
Any help much appreciated!! Thanks!