PrevCode = ""
A variable called PrevCode, We are assigning a text, which is looks like NOTHING, and has been stored in PrevCode Veriable.. using one of the Right Shift operator “=”, Left shift operator, means the value in right side of the operator, will be stored in the left side..
Do Until rs.EOF
Do the even until.. a connection called RecordSet, in short, somewhere someone denoted it as rs.. read the file, until you found a special string called EndOfFile.. a bookmark in each file.. whichsay where the file has ended.
CurrCode = Right(rs("Lot Rep Type ID").Value, 5)
One column named as “Lot Rep Type ID”. In this column, read its what was written there.. for example, it was “Thank You for your WORDS”, Just read only last 5 character
If CurrCode <> PrevCode Then
If last 5 digit is not equal to “” (Blank) then
RepCount = RepCount + 1
assign RepCount as previous value of RepCount + 1, for the first time RepCount is 0, in next true condition, it will increase to 2.. and so on
RepID(RepCount) = Right(rs("Lot Rep Type ID"), 5)
RepId is a Arry Variable, which can store multiple value in it.. For example RepId(0) = “WORDS”, RepId(1) = “WORLD”, RepId(2) = “THREE” and so on
End If
PrevCode = Right(rs("Lot Rep Type ID").Value, 5)
Now re-set PreCode from “” to WORLD, which was just came, in next step, re-set PreCode from WORDS to WORLD and so on..
rs.MoveNext
Move to the next RecordSet, in Excel language.. read Next Row
Loop
If you have not reached EOF (EndOfFile) go back to the Do Until Line, and Do again all above
'end 1.
OOPS! Luke M already did the job..
Thank God, Chandoo dont have any VBA Forensic Section..