+ Reply to Thread
Results 1 to 5 of 5

Validate three conditions and insert row

  1. #1
    Registered User
    Join Date
    07-29-2022
    Location
    Brazil
    MS-Off Ver
    2019
    Posts
    11

    Validate three conditions and insert row

    Dear
    I'm working with a macro (contributed by a colleague on the forum) that inserts a line below whenever the answer is PC or NC.
    ====
    Private Sub Worksheet_Change(ByVal Target As Range)
    On Error Resume Next
    If Not Intersect(Target, Range("V:V")) Is Nothing Then
    Application.EnableEvents = False
    Target = UCase(Target)
    Application.EnableEvents = True
    End If
    On Error GoTo 0

    If Target.Column <> 22 Or Target.Text <> "NC" And Target.Text <> "PC" Then Exit Sub
    Rows(Target.Row + 1).Insert
    Cells(Target.Row + 1, 23).Resize(, 42).Merge
    Cells(Target.Row + 1, 23).Select
    Cells(Target.Row + 1, 22).ClearContents
    End Sub
    ====

    How should be
    --------------------
    Block 1
    ---------------------
    Question 1 = C
    Question 2 = NC (Since the answer was NC, insert a line below question 2)
    Question 3 = C
    Question 4 = C
    Question 5 = PC (Since the answer was PC, insert a line below question 5)
    (As PC or NC answers appeared in this block, insert one more line below question 5)
    ---------------------
    Block 2
    ---------------------
    Question 1 = C
    Question 2 = C
    Question 3 = NC (Since the answer was NC, insert a line below question 3)
    (As PC or NC answers appeared in this block, insert one more line below question 3)
    ---------------------
    Block 3
    ---------------------
    Question 1 = C
    Question 2 = PC (Since the answer was PC, insert a line below question 2)
    Question 3 = C
    Question 4 = C
    (As PC or NC answers appeared in this block, insert a line below question 4)
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: Validate three conditions and insert row

    Please Login or Register  to view this content.
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    07-29-2022
    Location
    Brazil
    MS-Off Ver
    2019
    Posts
    11

    Re: Validate three conditions and insert row

    Hi Ben
    It's very good, but there are still minor adjustments to be made. I am resending the spreadsheet with these details.
    Thanks
    Attached Files Attached Files

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: Validate three conditions and insert row

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-29-2022
    Location
    Brazil
    MS-Off Ver
    2019
    Posts
    11

    Re: Validate three conditions and insert row

    It turned out great! Exactly what I need. Thank you very much

+ 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. [SOLVED] Validate / insert value based on another sheet of excel
    By COOL_GAVI in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-29-2021, 10:02 AM
  2. Insert a new Column when there's none under certain conditions
    By gabeBU in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-07-2018, 10:17 PM
  3. Insert rows in conditions
    By chris4204 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-02-2015, 04:13 AM
  4. How to insert more conditions in if-statement
    By dannyjoer in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-06-2014, 04:51 AM
  5. Validate two fields when one field you need a formula to validate
    By cmwilbur in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-29-2010, 11:32 AM
  6. How can I validate data using multiple conditions?
    By ajwhipple in forum Excel General
    Replies: 4
    Last Post: 09-26-2007, 05:59 PM
  7. How to multiple conditions to validate more than 2 conditions to .
    By Bhuvana Govind in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-28-2005, 04:06 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