+ Reply to Thread
Results 1 to 3 of 3

VBA Macro Issue - Trying to use macro to move row over to next sheet if column states "yes

  1. #1
    Registered User
    Join Date
    04-02-2018
    Location
    Vermont, USA
    MS-Off Ver
    Microsoft Office 365 Business
    Posts
    8

    VBA Macro Issue - Trying to use macro to move row over to next sheet if column states "yes

    Hi there! I had someone here help me out with a macro on this forum. The purpose of the macro was to copy information over to the next available row in the next sheet if the last column, column L, includes the text "Yes". If It states "No" it will not be copied over to the next sheet. I added a few addition columns to both sheets and now the macro is no longer doing anything. I tried to update the macro accordingly but I think I just messed it up further. Could you take a look at the macro below and help me improve it so it can provide the intended functionality? The columns I'd like to be pasted to the next sheet are A-K and the column that states yes or no in it is L. The initial sheet is called "Outreach" and if there is a "Yes" in Column L in "Outreach" it should pull over A-K to A-K in the following sheet "Relationship"

    Thank you!


    'LRowK = tbl.ListRows.Count + 2

    ' Find the record
    Set rng = Range("Table_Relationship[Influencer]").Find(Influencer, LookIn:=xlValues, lookat:=xlWhole)

    Select Case UCase(Answer)
    Case "YES"
    ' if the record is there, delete it and copy the new information in.
    If Not rng Is Nothing Then
    rng.EntireRow.Delete
    End If

    ' Get the row after the last row with data
    LRowK = tbl.ListRows.Count + 2

    ' Copy the data from source to destination
    shS.Range(shS.Cells(RowNum, "A"), shS.Cells(RowNum, "K")).Copy
    shD.Cells(LRowK, "A").PasteSpecial xlPasteValues

    ' Copy the notes
    shD.Cells(LRowK, "Q") = shS.Cells(RowNum, "G")
    Case "NO"
    ' Delete the record
    If Not rng Is Nothing Then
    rng.EntireRow.Delete
    End If

    End Select

    End Sub

    Sub clear()
    Application.ScreenUpdating = True
    Application.EnableEvents = True
    End Sub

  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: VBA Macro Issue - Trying to use macro to move row over to next sheet if column states

    See if this will do what you want.
    Please Login or Register  to view this content.
    Your original code indicates that the data might be in a table. If so, this code could fail.
    Last edited by JLGWhiz; 11-06-2018 at 04:07 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!

  3. #3
    Registered User
    Join Date
    04-02-2018
    Location
    Vermont, USA
    MS-Off Ver
    Microsoft Office 365 Business
    Posts
    8

    Re: VBA Macro Issue - Trying to use macro to move row over to next sheet if column states

    Hi there,
    Yes both sheets are tables. When I added this code, I received this message
    "Compile error:
    Sub or function not defined"

+ 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. Workbook_SheetChange macro deletes all "undo" ("redo") states
    By jakopak in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-16-2017, 04:24 PM
  2. Replies: 1
    Last Post: 06-04-2013, 03:01 PM
  3. Replies: 2
    Last Post: 09-10-2012, 03:02 AM
  4. Move Formula/Macro from column on one sheet to column(s) on another
    By getoffdee in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-22-2012, 03:34 PM
  5. Macro to CUT & Paste a row to another sheet if "Active" appears in Column J
    By Fferjay in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-20-2011, 12:25 PM
  6. VBA Code for deleting rows where cell in column a states "delete row"
    By tnfire in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-20-2009, 06:17 PM
  7. [SOLVED] "With Sheets" Issue - macro on one sheet to affect hidden rows on other sheets
    By Punsterr in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-21-2006, 12:10 AM

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