I'm trying to copy batches of rows, based upon one column's values.
The worksheet looks like this (sorted by the first column):
A 5 blue A 6 yellow B 3 red B 2 blue
The loop has 3 primary steps:
- Copy all rows beginning with a value, e.g. rows 1-2, which both begin with "A"
- Paste rows into an email (I know how to do this)
- Move to the value, B, and copy all rows starting with B
I won't know the 开发者_高级运维values of Column A, as they will change each time. Is there a way I can still write this loop?
2 possible approaches:
1: Rather than thinking of it as copying all the "A" rows at once, have a build string that you add to for each row, and then when you hit a new value for the first column, flush the build string into the email. That way its a single loop with a condition check in there.
2:
- Maintain a startPos. set it to 1.
- Loop through first col till value changes.
- Copy startRow - currentRow - 1 to email.
- set startPos = currentRow.
- Repeat.
精彩评论