I have a dated CS degree so I understand the basics of VB but I don’t write macros very often and need help solving a particular condition. (…but I understand functions and object oriented programming)
Assume the following:
– Column A contains reference ID’s in alphanumeric form, sorted alphabetically.
– Column B contains strings of text, or blanks.
I’m trying to write a macro that automatically removes any extra rows for each unique reference number based on the contents of the “Notes” in column B. The problem is that if column A has multiple instances of a unique ref number, I need to identify which row contains something in column B. There is one catch: it is possible that the reference number has nothing in column B and should be retained.
To explain further, in the following screenshot I would need to:
- Keep the yellow highlighted rows
- Delete the remaining rows
I tried to show various configurations of how the report might show the data using the brackets on the right and marked in red. Its difficult to explain what I’m trying to do so I figured a picture would show what I need more clearly.

This task is making the report very manual and time consuming.
it’s pretty simple
you just go throug the rows and check whether this row needs to be deleted, an earlier row with this id needs to be deleted or nothing should happen.
in my example i mark these rows and delete them in the end.
it could look something like this. the only thing you need is to add Microsoft Scripting Runtime in Tools/References