Results 1 to 8 of 8

Stop Macro bringing across duplicate data

Threaded View

excel_learner2 Stop Macro bringing across... 02-08-2018, 12:28 PM
TMS Re: Stop Macro bringing... 02-08-2018, 12:41 PM
ranman256 Re: Stop Macro bringing... 02-08-2018, 12:41 PM
TMS Re: Stop Macro bringing... 02-08-2018, 12:43 PM
excel_learner2 Re: Stop Macro bringing... 02-08-2018, 12:53 PM
excel_learner2 Re: Stop Macro bringing... 02-09-2018, 10:06 AM
TMS Re: Stop Macro bringing... 02-09-2018, 05:24 PM
jindon Re: Stop Macro bringing... 02-09-2018, 10:13 PM
  1. #1
    Registered User
    Join Date
    10-31-2017
    Location
    Liverpool, England
    MS-Off Ver
    2013
    Posts
    5

    Stop Macro bringing across duplicate data

    Hi all,

    I've found some help on here in the past, so thought I would try my luck again.

    I currently have a Workbook that is pulling data from one sheet to another based on the value of a specific row. I need it to read the value "Yes" in one of the columns and copy the entire row to the new sheet. I have acheived this, created a button to run the Macros and copy the data over. All seems fine, however if you click the button again, it brings the data over again.

    I need something that will enable the Macros to check if the value in Column B is already present, then it will not copy across. Please see the current code below:

    Sub MoveRowBasedOnCellValue()
    
        Dim xRg As Range
        Dim xCell As Range
        Dim i As Long
        Dim J As Long
        Dim K As Long
        i = Worksheets("Open Cases").UsedRange.Rows.Count
        J = Worksheets("Uncollectables").UsedRange.Rows.Count
        If J = 1 Then
        If Application.WorksheetFunction.CountA(Worksheets("Uncollectables").UsedRange) = 0 Then J = 0
        End If
        Set xRg = Worksheets("Open Cases").Range("R1:R" & i)
        On Error Resume Next
        Application.ScreenUpdating = False
        For K = 1 To xRg.Count
            If CStr(xRg(K).Value) = "Yes" Then
                xRg(K).EntireRow.Copy Destination:=Worksheets("Uncollectables").Range("A" & J + 1)
                J = J + 1
            End If
        Next
        Application.ScreenUpdating = True
    End Sub
    Just to reiterate that the above works for the initial purpose of what I wanted, I just need it so that every time the button is clicked to update the new tab (we will need to do this each day) it checks if the data is already present.

    If an example work book is required I can try and sort this out, but the nature of my work is quite sensitive so ideally I would not do this.

    Hoping somebody is able to help! Thanks
    Last edited by excel_learner2; 02-08-2018 at 12:51 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Macro check as bringing wrong line through
    By aaaaaaiden in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-12-2014, 06:11 AM
  2. [SOLVED] Stop Vlookup bringing back 0's or #REF! and bring back blanks instead
    By Carling73 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-30-2013, 04:43 PM
  3. Stop macro at the end of data / make macro faster
    By Shaner73 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 08-17-2010, 08:14 AM
  4. bringing up the data -> form... box via macro
    By mdkruse2 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-30-2008, 04:01 PM
  5. bringing up the data -> form... box via macro
    By splodgecat in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-17-2007, 06:52 PM
  6. Stop Macro if there is no data
    By STEVEB in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 02-08-2006, 05:45 PM
  7. Bringing up the Unhide Sheet list via macro
    By PCLIVE in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-22-2005, 02:45 PM
  8. How do you Stop Entering Duplicate Data in a Column?
    By Satraj in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 11-04-2005, 09: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