![]() |
|
|
|
#1
|
||||
|
||||
|
You're probably new to this, so I won't give you a hard time about it, but you're going to have to do a lot better than that when reporting problems. "It didn't work" isn't nearly enough information for others to figure out what's going wrong. To start with, what did it do (and what did you do first)—and I mean exactly what did it do? Details, man, details!
![]() But one of the nice things about VBA in Excel is that you can step through the program and watch what it does one statement at a time. Try this: In the VBA Editor (where you're looking at your program, not at the Excel worksheet), look at the menu bar and select Debug. In the drop-down list notice some of your options: You can hit <F8> ("Step Into") to execute just the next statement in your program. You can hit <Shift-F8> to do the same thing, only if it's a call to a subroutine it'll execute the whole subroutine and stop at the next statement. (Try it and you'll see what I mean.) You can hit <F5> just to run the program in the normal way. And so on. Now exit the drop-down menu, and while looking at your program hit <F8>. The first line of the program will light up in yellow; hit <F8> again and it'll move to the next statement, and so on one statement at a time. At any point you can mouseover a variable and see what the value is, if it's scalar; if it's an object you can "Add Watch" for that object to see all its properties displayed in a special Watch window. This is invaluable in seeing exactly what your program is doing at each point in the program. If you've never done this before, feel free to ask questions to help you understand what it's doing and how you can use it. |
|
#2
|
|||
|
|||
|
tmill29, please upload a sample file with your data structure, in those 2 sheets, it will increase your chances to receive an answer...
The following code might do what you need, but is not tested on your data: Code:
Sub HighlightRowsWithMyNumbers()
Dim cell As Object
Dim i As Integer
Application.ScreenUpdating = False
On Error Resume Next
For Each cell In Sheets("sheet1").UsedRange
i = Application.Match(cell, Sheets("sheet2").Range("a2:a226"), 0)
If Not Err.Number <> 0 Then
Sheets("Sheet1").Rows(cell.Row).EntireRow.Interior.Color = vbYellow
End If
Err.Clear
Next cell
On Error GoTo 0
Application.ScreenUpdating = True
End Sub
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How do I assign a macro to a button when the macro is in my personal workbook? | foolios | Excel Programming | 2 | 07-27-2011 02:41 PM |