VBA: Cbeck cell if empty, dependent on other cells
Results 1 to 4 of 4

Thread: VBA: Cbeck cell if empty, dependent on other cells
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    May 2019
    Posts
    27
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default VBA: Cbeck cell if empty, dependent on other cells

    Header1 Header2 Header3
    Cat

    Hello there,

    I currently have this code:

    Set CheckC = Range("B2")
    If Range("A2") = Value And Range("B2") = "" Then
    MsgBox "You cannot transfer until required information has been completed." & _
    vbCrLf & vbNewLine & "Check for cells with light blue markings (All cells highlighted in light blue must be completed.)"
    CheckC.Select
    If Range("A2") = Value And IsEmpty(CheckC) Then Application.ScreenUpdating = True
    Application.EnableEvents = True
    Exit Sub
    End If

    My goal is, if the user has data in column A, then the corresponding B column must be filled out. So, if A2 is filled out, then B2 must also be filled out and this is applied to the entire set of data. Any help is much appreciated! I'm not VBA-savvy so if the code above is not making sense (well, obviously it's not because it's not working), please forgive me...

  2. #2
    Board Regular
    Join Date
    Nov 2013
    Location
    Denver, Colorado - XFD1048576 - MORE Stuff here near the end. And what if you add even more stuff a
    Posts
    615
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA: Cbeck cell if empty, dependent on other cells

    Hi JennV - Welcome to the forum. Maybe this will help get things started. Please explain what happens when you run your code. That may help us help you. Hope this helps.
    Happy Excelling ,

    goesr

    To enter code in your post use the format below. Click the link for more detail.
    [CODE] ... Your Code Here ... [/CODE]

  3. #3
    MrExcel MVP
    Join Date
    Jan 2008
    Posts
    14,808
    Post Thanks / Like
    Mentioned
    25 Post(s)
    Tagged
    11 Thread(s)

    Default Re: VBA: Cbeck cell if empty, dependent on other cells

    Try this "Worksheet_Change" event :-
    Paste entire code in Worksheet Module (Alt + F11")

    Code:
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim Rng As Range, Dn As Range
    Set Rng = Range("A2", Range("A" & Rows.Count).End(xlUp))
    Set Rng = IIf(Rng.Address(0, 0) = "A1:A2", Range("A2"), Rng)
    For Each Dn In Rng
    If Dn <> "" And Dn.Offset(, 1) = "" Then
        If Not Target.Address = Dn.Address Then
            MsgBox "Please enter data in " & Dn.Offset(, 1).Address
            Application.EnableEvents = False
                Target = ""
            Application.EnableEvents = True
        Exit For
        End If
    End If
    Next Dn
    End Sub
    Regards Mick
    Last edited by MickG; Jun 13th, 2019 at 11:24 AM.

  4. #4
    New Member
    Join Date
    May 2019
    Posts
    27
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA: Cbeck cell if empty, dependent on other cells

    Thank you both! My issue has been resolved

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •