+ Reply to Thread
Results 1 to 3 of 3

Adding new rows using VBA everytime there is an "Error"

  1. #1
    Registered User
    Join Date
    06-16-2019
    Location
    London
    MS-Off Ver
    MS Office 2018
    Posts
    2

    Exclamation Adding new rows using VBA everytime there is an "Error"

    Hi All,

    I'm new into my employment and my manager said to code, even though I don't know how. LONG STORY!!! D:

    How can I create a macro code that loops everytime there is an error in any 3 of the fields A/C Ref (cell P1), CC (cell Q1) and DP (cell R1) column.
    I want to add a new row, based on the dataset, from Cell K6:V6 if there are any errors in either Cell P6, Q6 or R6. And yes, I want to know if
    this can be done for everytime there is ""Error"" throughout the data set."

    I can't upload my dataset but I hope the above helps.

    Thanks in Advance

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Adding new rows using VBA everytime there is an "Error"

    Not sure I really understand your issue, but you can try this. The code should be copied and pasted to the worksheet code module of the sheet where you want the rows inserted. This code will run when a user makes a change to the worksheet. If the change is in columns P, Q or R it will evaluate the entry to determine if an error resulted. If it is an error, it will insert a row immediately beneath the row the entry was made on. To access the code module, right click the sheet name tab, then click 'View Code' in the pop up menu. After posting the code, save the file and close the editor. The code will then run when any change is made to the sheet but will only execute the insert if there is an error in one of the three columns. It will not execute if more than one cell is changed at a time.

    Please Login or Register  to view this content.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  3. #3
    Registered User
    Join Date
    06-16-2019
    Location
    London
    MS-Off Ver
    MS Office 2018
    Posts
    2

    Re: Adding new rows using VBA everytime there is an "Error"

    Thanks a lot. It works now:D

+ 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. Replies: 35
    Last Post: 01-13-2016, 02:16 AM
  2. "Add Row" and "Remove Row" Buttons... adding rows with formulas down filled
    By excelatnothing in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-15-2015, 02:44 AM
  3. = EMBED("Forms.ComboBox.1","") error "Reference not valid."
    By CatharinaCatharina in forum Excel General
    Replies: 2
    Last Post: 12-11-2014, 09:58 AM
  4. Adding multiple "find" with "left" /"Right"
    By Daniel1 in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 02-22-2014, 04:33 PM
  5. [SOLVED] If Not ActiveSheet.Range("A1").Value Like "apple" Then MsgBox "Error"
    By HerryMarkowitz in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-18-2014, 02:16 PM
  6. Replies: 1
    Last Post: 09-21-2013, 03:18 AM
  7. [SOLVED] How to Count number of "Error" and "OK" after the word "Instrument" found in table row
    By eltonlaw in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-17-2012, 06:26 AM

Tags for this Thread

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