+ Reply to Thread
Results 1 to 2 of 2

automatically add row that contains correct vba

  1. #1
    Registered User
    Join Date
    11-13-2018
    Location
    england
    MS-Off Ver
    office 365
    Posts
    1

    automatically add row that contains correct vba

    I have created a sheet for my team to use when we are sending away damaged items the sheet has an away and returned drop down with away auto sorting to the top, i was looking for a way to make one blank row appear at position 2 (just below the headers) that will still contain all the correct vba in the specific columns and when it is filled in a new one to take its place, any help would be appreciated.

    Here is the current macro i made if this will be needed as it has the auto sort feature in it.

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Cells(Target.Row, "F") > 0 Then
    Cells(Target.Row, "A").Select
    Else
    If Cells(Target.Row, "A") = "Away" Then
    Cells(Target.Row, "F") = Now()
    End If
    End If

    If Cells(Target.Row, "G") > 0 Then
    Cells(Target.Row, "A").Select
    Else
    If Cells(Target.Row, "A") = "Returned" Then
    Cells(Target.Row, "G") = Now()
    End If
    End If
    If Not (Application.Intersect(Worksheets("WRIST UNITS").Range("A:A"), Target) Is Nothing) Then
    DoSort
    End If
    End Sub
    Private Sub DoSort()
    Worksheets("WRIST UNITS").Range("A1").CurrentRegion.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlYes
    End Sub
    Last edited by LewisO90; 11-13-2018 at 02:47 PM.

  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: automatically add row that contains correct vba

    I think if you just replace the DoSort procedure with this modified version, it would work for you after you insert the blank row 2.
    Please Login or Register  to view this content.
    Last edited by JLGWhiz; 11-13-2018 at 03:18 PM.
    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!

+ 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. Macro to Automatically Format Cell to Correct Height
    By Cardan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-16-2015, 05:25 PM
  2. Automatically correct one sheet with data from another?
    By bvercher in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-06-2015, 10:55 AM
  3. [SOLVED] Automatically find correct invoicing month
    By Deventus in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-15-2013, 07:21 AM
  4. [SOLVED] Equation(s) That Will Automatically Find Bad Data And Correct It.
    By garrett.grillo in forum Excel General
    Replies: 3
    Last Post: 10-26-2012, 04:16 PM
  5. [SOLVED] How to change column letters to correct ones in many formulas automatically?
    By Dmitry Kopnichev in forum Excel General
    Replies: 7
    Last Post: 10-13-2005, 05:05 PM
  6. [SOLVED] How to change column letters to correct ones in many formulas automatically?
    By Dmitry Kopnichev in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-13-2005, 05:05 PM
  7. [SOLVED] Automatically creating the correct number of dated columns
    By Struggling of Essex in forum Excel General
    Replies: 3
    Last Post: 04-25-2005, 01:06 PM

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