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 8514965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:00:45+00:00 2026-06-11T05:00:45+00:00

I have two columns, Column (A) and Column (B) in a spreadsheet. Column (A)

  • 0

I have two columns, Column (A) and Column (B) in a spreadsheet.

Column (A) contains names extracted from a query (ex. Brian, Bob, Bill, etc…) and column (B) contains one of three statuses (Assigned, In Progress, or Pending).

However, this query sometimes pulls up some line items showing “Assigned” for the status with no name, therefore corresponding cell representing the name in Column (A) is blank. So I manually fill in those empty cells with “Unknown”.

What I want to do is to create a macro that finds the every empty cell in column (A) and fill in the word “Unknown” if the cell to its right contains the word “Assinged”.

So the conditions are:

  1. Blank cell in column (A)

  2. Correspoding cell to its right (column B) contains the word “assinged”

This is my Code:

Private Sub CommandButton2_Click()

    For Each cell In Columns("A")
        If ActiveCell.Value = Empty And ActiveCell.Offset(0, 1).Value = "Assigned" Then ActiveCell.Value = "Unknown"
    Next cell

End Sub   
  • 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-11T05:00:47+00:00Added an answer on June 11, 2026 at 5:00 am

    Welcome to SO.

    Try this code. It will work a bit faster and should get you what you want.

    Update: Made the code more bullet proof!

    Private Sub CommandButton2_Click()
    
    Dim cel As Range, rngFind As Range, rngFilter As Range
    Dim wks As Worksheet
    
    Set wks = Sheets("sheet1")
    
    With wks
    
        '-> Error check to make sure "blanks" exist
        Set rngFind = .Range("A1:A" & .Range("B" & Rows.Count).End(xlUp).Row).Find("", lookat:=xlWhole)
    
        If Not rngFind Is Nothing Then
    
            Set rngFilter = .Range("A1:B" & .Range("B" & Rows.Count).End(xlUp).Row)
    
            rngFilter.AutoFilter 1, "="
    
            '-> Error check to make sure "assigned" exists for blank cells
            Set rngFind = .Columns("B:B").SpecialCells(xlCellTypeVisible).Find("Assigned", lookat:=xlWhole)
    
            If Not rngFind Is Nothing Then
            '-> okay, it exists. filter and loop through cells
    
                rngFilter.AutoFilter 2, "Assigned"
    
                Set rngFind = Intersect(.UsedRange, .UsedRange.Offset(1), .Columns(1)).SpecialCells(xlCellTypeVisible)
    
                For Each cel In rngFind
    
                    If cel.Offset(0, 1).Value = "Assigned" Then cel.Value = "Unknown"
    
                Next cel
    
            End If
    
        End If
    
    End With
    
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an excel spreadsheet with two columns, one with a list of exercises
I have two columns in a QTreeWidget , one column represents a list of
I have an Arraylist of HashMap . Each HashMap element contains two columns: column
I have an excel spreadsheet with two columns. The first column is a label
I have an excel spreadsheet that has two columns. When I choose to save
I have two columns. Column E extends up to 99504 (values) and column I
I have a table with two columns: column A column B 1 2 1
I have two data frames with two columns each. The first column is timestamps
In a frame I have two columns. In the first column I display some
I have a jTable with two columns.First column is set as Boolean(for checkbox) and

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.