Determine if Excel TextBox is blank

Posted on 2012-08-30
Last Modified: 2012-08-30
Hello All, I am stumped. I have textbox's from many files that I'm working on pulling into a single document, the only issue I have is this. I need to have some vba code to check if the textbox is empty. When completed the main file will pull in data from up to four workbooks. I do not want to pull in an empty textbox and waste space on the page that will be printed. This will obviously not be a good looking finished product. I have attached a single department sheet with dummy data in it. Each department sheet allows them to populate up to a month of data in one sheet and when my main file opens the department sheet it pulls the textbox for todays date to Linked Textbox Sheet and imports it into the main file.
Question by:peetjh
    LVL 10

    Accepted Solution

    After this statement:
    ActiveSheet.Shapes.Range(Array("TextBox " & Cells(2, "D").Value)).Select

    You can examine Selection.Text; for example:
    If Selection.Text <> "" Then
        ' handle non-empty text box
    End If
    LVL 14

    Author Closing Comment

    Thanks, I was stuck trying to get the same result with if Textbox 1 or whichever <>"" and it would not work. It's not very often I need to use the selection properties.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    What is a Form List Box? (skip if you know this) The forms List Box is the alternative to the ActiveX list box. If you are using excel 2007, you first make sure you have a developer tab (click the Orb)->"Excel Options"->Popular->"Show Developer tab…
    Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
    Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
    Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now