D
davegb
I am learning VBA for Excel (v2000) under pressure. We have large
spreadsheets (at least by my standards, 10,000 to 32,000 rows) in which
I need to find existing flags and add flags above and below the
existing flags based on 2 criteria which exist in the same row as the
value I'm testing and changing. (I'm slightly simplifying the scenario
because I think if I can get help with this part, I can do the rest.)
In these spreadsheets, Col A contains an ID value (alphanumeric), Col B
I don't care about, Col C is a flag, 0 or 1, Col D is an alpha field,
Col E is a date. I've given each column a range name thinking that
might make the macro easier to write. The solution can use the range
names or not.
The macro should look for the value "1" in column C (named range
"rangeC"), then save the Row number as iBaseRow. Then I want to get the
corresponding value in Column A (named range "rangeA") and saves it as
"strBaseSID") and the date in column E as "iBaseDate". Then I want it
to go up one row and test to see if the value in column A is the same
as strBaseSID. If yes, then move on to compare the date from the same
row to see if it's equal to or greater than iBaseDate -90. If the
ID's or dates don't match, continue the macro one row below the
BaseRow. If both criteria are met, the flag in Col C should be set to
1. Then it should move up one row and repeat the process. I hope this
explanation is clear. Can anyone help me with this?
TIA
spreadsheets (at least by my standards, 10,000 to 32,000 rows) in which
I need to find existing flags and add flags above and below the
existing flags based on 2 criteria which exist in the same row as the
value I'm testing and changing. (I'm slightly simplifying the scenario
because I think if I can get help with this part, I can do the rest.)
In these spreadsheets, Col A contains an ID value (alphanumeric), Col B
I don't care about, Col C is a flag, 0 or 1, Col D is an alpha field,
Col E is a date. I've given each column a range name thinking that
might make the macro easier to write. The solution can use the range
names or not.
The macro should look for the value "1" in column C (named range
"rangeC"), then save the Row number as iBaseRow. Then I want to get the
corresponding value in Column A (named range "rangeA") and saves it as
"strBaseSID") and the date in column E as "iBaseDate". Then I want it
to go up one row and test to see if the value in column A is the same
as strBaseSID. If yes, then move on to compare the date from the same
row to see if it's equal to or greater than iBaseDate -90. If the
ID's or dates don't match, continue the macro one row below the
BaseRow. If both criteria are met, the flag in Col C should be set to
1. Then it should move up one row and repeat the process. I hope this
explanation is clear. Can anyone help me with this?
TIA