+ Reply to Thread
Results 1 to 8 of 8

Make column cell input mandatory if initial cell has input

  1. #1
    Registered User
    Join Date
    11-22-2017
    Location
    Sydney
    MS-Off Ver
    2016
    Posts
    10

    Question Make column cell input mandatory if initial cell has input

    Hi There,

    I found that page on the forum and it has helped me to make cells input mandatory if initial cell has input.

    below what I found:
    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Cancel = False
    Application.EnableEvents = True

    If Trim(Range("E8")) <> "" Then
    If Trim(Range("F8")) = "" Then Cancel = True
    If Trim(Range("G8")) = "" Then Cancel = True
    If Trim(Range("H8")) = "" Then Cancel = True
    End If

    If Range("H8") = "No" Then
    If Trim(Range("D18")) = "" Then Cancel = True
    If Trim(Range("E18")) = "" Then Cancel = True
    If Trim(Range("F18")) = "" Then Cancel = True
    End If

    If Trim(Range("E9")) <> "" Then
    If Trim(Range("F9")) = "" Then Cancel = True
    If Trim(Range("G9")) = "" Then Cancel = True
    If Trim(Range("H9")) = "" Then Cancel = True
    End If

    If Range("H9") = "No" Then
    If Trim(Range("D18")) = "" Then Cancel = True
    If Trim(Range("E18")) = "" Then Cancel = True
    If Trim(Range("F18")) = "" Then Cancel = True
    End If

    If Cancel = True Then MsgBox "Please fill in all the cells required."

    End Sub


    However, it's working for only a cell and I'm looking to select a whole column. I've tried many different ways but I cannot find something that works.
    Would help me with that?

    Thanks,

  2. #2
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Make column cell input mandatory if initial cell has input

    One way
    - test all the cells in range C2 to C10 using VBA

    Please Login or Register  to view this content.
    Note
    - every cell in given range must have a value
    - it makes no sense to apply to a whole columns - there will be some empty cells
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  3. #3
    Registered User
    Join Date
    11-22-2017
    Location
    Sydney
    MS-Off Ver
    2016
    Posts
    10

    Re: Make column cell input mandatory if initial cell has input

    Hi,

    Thank you for your answer. I'll test that ASAP.

    Regarding your note and the second point. I needed the whole column when someone starts to add something in that specific column.
    Indeed, I send my excel to someone who has to fill it. When they start to fill the column A for example, I need mandatory info in the column B. However, I will not know in advance how many rows they will need in the column A. Can the BVA works only if there is something in the column A? I hope my example is clear. :-)

    Thank in advance

  4. #4
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Make column cell input mandatory if initial cell has input

    Here you go:
    - first row is 2
    - last row is determined by last value in columnA
    - cells in columnB in that range must contain a value

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    11-22-2017
    Location
    Sydney
    MS-Off Ver
    2016
    Posts
    10

    Re: Make column cell input mandatory if initial cell has input

    Thank you so much for your help.
    Can i ask you one more thing?
    That is working for a column, can i add a requested cell is another cell content is Yes or is it too hard?

    Thank you,
    Attached Images Attached Images
    Last edited by Joceau; 11-27-2017 at 07:40 PM.

  6. #6
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Make column cell input mandatory if initial cell has input

    I do not understand your question
    Are you wanting VBA to use the value input in one cell to determine which cells must not be empty?
    - perhaps you could explain with a couple of examples

  7. #7
    Registered User
    Join Date
    11-22-2017
    Location
    Sydney
    MS-Off Ver
    2016
    Posts
    10

    Re: Make column cell input mandatory if initial cell has input

    I think i found how to do :-)

    Thanks again for your help!

  8. #8
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Make column cell input mandatory if initial cell has input

    If that answers your original question please mark thread as SOLVED (Thread Tools at top of thread)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Make multiple cell input mandatory if initial cell has input.
    By dwporter in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 11-23-2017, 08:06 PM
  2. Mandatory Cell Input
    By red1234 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-13-2016, 11:16 AM
  3. [SOLVED] Mandatory Input based on another cell
    By gaker10 in forum Excel General
    Replies: 1
    Last Post: 07-31-2015, 03:14 PM
  4. Save file using cell references & mandatory cell input
    By Plantation in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-22-2013, 12:46 PM
  5. Replies: 14
    Last Post: 01-22-2013, 12:07 PM
  6. how to generate error message for an empty cell (mandatory input cell)
    By asankar24 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-20-2012, 12:37 PM
  7. To make several cells mandatory based on other cell input.
    By nukecity83 in forum Excel General
    Replies: 1
    Last Post: 10-13-2009, 05:35 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1