Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50049

Macro to Recognize Data Input Categories

$
0
0
Hi everyone, I am looking for a simple macro that will look down a variable length column (column C in the Data sheet in the attached workbook) and determine whether a "Y" should be entered into the "Gross" column, the "ON" column or the "BC" column or none of the three columns.

Criteria:

The data in column C is input in "sets".

A set of data can include a line that contains 1) "ontario" , 2) "BC", 3) both "Ontario" and "BC" or 4) neither.

If a data set does not have a line that contains either an "Ontario" or a "BC" line, then there not be any "Y"'s entered for any lines in that data set. An example of this type of data set is on rows 4 & 5.

If a data set includes a line with either "Ontario" or "BC", I need the Ontario line to have a "Y" in the "ON" column (column "H") and the BC line to have a "Y" in the "BC" column (column I) and all other (Description) lines in the dataset to have "Y" entered in the "Gross" column (column "G").

An interesting twist is the data set on rows 40 to 43. As this data set has crossed over a page break, the macro needs to recognize that the "Ontario" line is part of the data set above it even though it is separated by one or more blank lines. The simplest way to describe this eventuality is that any line containing either Ontario or BC must have at least one description line above it, even if separated by blank lines.

Any helpful suggestions on how to approach this would be appreciated.

Regards,

Craig
Attached Files

Viewing all articles
Browse latest Browse all 50049

Trending Articles