Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8006683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:35:41+00:00 2026-06-04T17:35:41+00:00

I have a dated CS degree so I understand the basics of VB but

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T17:35:43+00:00Added an answer on June 4, 2026 at 5:35 pm

    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.

    Sub foo()
    Dim rngSelection As Range
    Dim startingRow As Integer
    Dim endRow As Integer
    Dim idColumn As Integer
    Dim noteColumn As Integer
    Dim idValuableRow As New Dictionary
    Dim deleteRows As New Collection
    
    Set rngSelection = Selection
    startingRow = rngSelection.Row
    endRow = rngSelection.Rows.Count + startingRow - 1
    
    
    idColumn = rngSelection.Column
    noteColumn = idColumn + 1
    
    For i = startingRow To endRow
        currentID = Cells(i, idColumn)
        If idValuableRow.Exists(currentID) Then
            If Trim(idValuableRow(currentID)("note")) <> "" And Trim(Cells(i, noteColumn)) = "" Then
                deleteRows.Add i
             ElseIf idValuableRow(currentID)("note") = "" And Trim(Cells(i, noteColumn)) <> "" Then
                deleteRows.Add idValuableRow(currentID)("row")
                idValuableRow(currentID)("row") = i
                idValuableRow(currentID)("note") = Cells(i, noteColumn)
            End If
        Else
            Dim arr(2) As Variant
            idValuableRow.Add currentID, New Dictionary
            idValuableRow(currentID).Add "row", i
            idValuableRow(currentID).Add "note", Cells(i, noteColumn)
        End If
    
    
    Next i
    deletedRows = 0
    For Each element In deleteRows
        If element <> "" Then
            Rows(element - deletedRows & ":" & element - deletedRows).Select
            Selection.Delete Shift:=xlUp
            deletedRows = deletedRows + 1
    
            End If
        Next element
    
    End Sub
    

    it could look something like this. the only thing you need is to add Microsoft Scripting Runtime in Tools/References

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Many PCs we have on the development team are out-dated and are very slow
I am trying to have information displayed for this query: SELECT o.sub_number,o.unique_id,o.period_from,o.period_to,o.total_amt, i.paid_amt,i.dated,i.payment,i.paid_by,i.entered_date,i.paid_for_unique, j.cheque_num,j.drawn_on,j.dated
i have one problem while making a query wellid dated drillid 1 2000-05-01 11:30:00
I have a dated system perl 5.8.8 on a Linux machine and installed a
I have a table with dated records. I want a query that will show
I have a datasource which contains dated items per row. These will be bound
Hello Friends i have the following query which defeat the very purpose. A day
I need to create a JasperReport in iReport that lists employees info including degree
Say I have an old class, dated from c# 1.1 and I would like
i have written the following code but it is giving parse error . here

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.