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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:31:22+00:00 2026-06-07T10:31:22+00:00

If a cell is empty, I want it to look in the cell above.

  • 0

If a cell is empty, I want it to look in the cell above. If that one is empty, it will look in the cell above that until it finds a non-empty cell. When it does, it should return it. It’ll be a UDF called loopUp. Then, when I use it in a cell formula like so: =loopUp(D24), and the range D18:D24 is empty, it’ll show what is in D17.

Here’s some Psuedo:

Function loopUp(Cell)
    while Cell is empty
        Cell becomes cell above
    return cell

I am new to VBA. The thing I am stuck on is how to pass in the address of a cell rather than its value.

  • 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-07T10:31:26+00:00Added an answer on June 7, 2026 at 10:31 am

    Following Siddharth’s last suggestion, here is a way to tackle it.

    Function LoopUp(rng As Range) As Variant
    
    Dim intCnt As Long
    
    LoopUp = "Nothing found"
    
    For intCnt = rng.Row To 1 Step -1
        If Not IsEmpty(Cells(intCnt, rng.Column)) Then
            LoopUp = Cells(intCnt, rng.Column)
            Exit For
        End If
    Next
    
    
    End Function
    

    UPDATE

    This may be a better, cleaner, easier to understand solution. I tested it a bit, but someone may break it!

    Function LoopUp(rng As Range) As Variant
    
    If Not IsEmpty(rng) Then LoopUp = rng
    Else
        If rng.End(xlUp).Row = 1 Then LoopUp = "Nothing found" Else LoopUp = rng.End(xlUp)
    End If 
    
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write an XPath expression that selects all non-empty table:table-cell children of
wsIMP.Columns(4).SpecialCells(xlCellTypeBlanks).EntireRow.Delete The code will delete everything in D that is an empty cell, which
Cell A4 has latitude and longitudes like this 33.7998709,-84.3432666. I want cell A5 should
Q: I want to check the DateTime against null value to empty the cell
I want to generate a pdf report, where a column(or cell/field) is left blank(empty)
how to detect grid view empty cell ? I need it for highlighting. So
How do I check if a CELL in excel sheet is empty and doesn't
That's how cell selection looks in MS Excel: Is it possible to have the
I'm looking for a grid control that works like UniformGrid, except that it should
I want to use jQuery to check if the 2nd cell in each table

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.