Hi,
I want to loop through a set of data. For each activecell.value, search for it in a defined string array. If there is a match, then do something with that activecell. Here are some more specifics.
My array: courses = ("a","b","c","d","e")
My data:
<table class="cms_table" width="146"><tbody><tr><td style="vertical-align: top;">date
</td><td style="vertical-align: top;">course
</td><td style="vertical-align: top;">days
</td></tr><tr class="cms_table_tr" valign="top"><td class="cms_table_td">08/08/2011</td> <td class="cms_table_td">a</td> <td class="cms_table_td">2</td> </tr> <tr class="cms_table_tr" valign="top"><td class="cms_table_td">09/08/2011</td> <td class="cms_table_td">b</td> <td class="cms_table_td">1</td> </tr> <tr class="cms_table_tr" valign="top"><td class="cms_table_td">09/08/2011</td> <td class="cms_table_td">z</td> <td class="cms_table_td">1</td> </tr> <tr class="cms_table_tr" valign="top"><td class="cms_table_td">09/08/2011</td> <td class="cms_table_td">a</td> <td class="cms_table_td">5</td> </tr> <tr class="cms_table_tr" valign="top"><td class="cms_table_td">10/08/2011</td> <td class="cms_table_td">z</td> <td class="cms_table_td">2</td> </tr> </tbody></table>
I want to make a new sheet, which is a condensed version the table above. It only contains the data for the courses defined in the array.
VB:
Sub x() 'array courses stored codecodecode
ActiveSheet.Range("A2").Activate Do Until IsEmpty(ActiveCell) On Error Goto HERE m = Application.WorksheetFunction.Match(ActiveCell.Value, courses, 0) MsgBox "no problems " & m Rows(ActiveCell.Row).Copy Worksheets("Courses").Activate ActiveCell.PasteSpecial ActiveCell.Offset(1, 0).Select Worksheets("data").Activate HERE: ActiveCell.Offset(1, 0).Activate Loop End Sub
It correctly ignores the first error, which is the first 'z'. Once it gets the the second z, I get run-time error '1004': unable to get the Match property.
Why am I getting this error?
I want to loop through a set of data. For each activecell.value, search for it in a defined string array. If there is a match, then do something with that activecell. Here are some more specifics.
My array: courses = ("a","b","c","d","e")
My data:
<table class="cms_table" width="146"><tbody><tr><td style="vertical-align: top;">date
</td><td style="vertical-align: top;">course
</td><td style="vertical-align: top;">days
</td></tr><tr class="cms_table_tr" valign="top"><td class="cms_table_td">08/08/2011</td> <td class="cms_table_td">a</td> <td class="cms_table_td">2</td> </tr> <tr class="cms_table_tr" valign="top"><td class="cms_table_td">09/08/2011</td> <td class="cms_table_td">b</td> <td class="cms_table_td">1</td> </tr> <tr class="cms_table_tr" valign="top"><td class="cms_table_td">09/08/2011</td> <td class="cms_table_td">z</td> <td class="cms_table_td">1</td> </tr> <tr class="cms_table_tr" valign="top"><td class="cms_table_td">09/08/2011</td> <td class="cms_table_td">a</td> <td class="cms_table_td">5</td> </tr> <tr class="cms_table_tr" valign="top"><td class="cms_table_td">10/08/2011</td> <td class="cms_table_td">z</td> <td class="cms_table_td">2</td> </tr> </tbody></table>
I want to make a new sheet, which is a condensed version the table above. It only contains the data for the courses defined in the array.
VB:
Sub x() 'array courses stored codecodecode
ActiveSheet.Range("A2").Activate Do Until IsEmpty(ActiveCell) On Error Goto HERE m = Application.WorksheetFunction.Match(ActiveCell.Value, courses, 0) MsgBox "no problems " & m Rows(ActiveCell.Row).Copy Worksheets("Courses").Activate ActiveCell.PasteSpecial ActiveCell.Offset(1, 0).Select Worksheets("data").Activate HERE: ActiveCell.Offset(1, 0).Activate Loop End Sub
It correctly ignores the first error, which is the first 'z'. Once it gets the the second z, I get run-time error '1004': unable to get the Match property.
Why am I getting this error?