+ Reply to Thread
Results 1 to 14 of 14

Check duplicate from userform values before pasting to worksheet VBA

  1. #1
    Forum Contributor
    Join Date
    09-02-2013
    Location
    London
    MS-Off Ver
    Excel 2019
    Posts
    368

    Check duplicate from userform values before pasting to worksheet VBA

    Hello,
    I'm trying to record data by using a userform which will then write/paste values of boxes in the userform to a Sales worksheet. Instead of writing/pasting directly values on the userform, I would like first once the userform 'Record' button is clicked to check whether 2 values (Supplier and Reporting Month) of the userform are not already recorded on the worksheet. If these 2 values exist already simultaneously, then a "Duplicate" message box pops. Then Exit the Sub and clear all the contents of the userform. Otherwise, it will write the userform values to a new line (row) on the Sales worksheet.

    There were many ways of achieving the intended result nut I wonder if there is something simple and easy. I was thinking about using a evaluate command to use with Match function to render the formula on the worksheet Cell B15:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Below is the workbook I wrote with some help to achieve it. The issue though is that it doesn't do what it is intended to do.

    Your help is very much appreciated. Thank you.
    Attached Files Attached Files

  2. #2
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,293

    Re: Check duplicate from userform values before pasting to worksheet VBA

    A simple flag will do what you want but one of the criteria you have chosen is a date which whatever way it is copied to sheet can throw up formatting problems. I tool a look at it and set the flag to work for columns "G" and instead of "O" I used "F" so if both comboBoxes values are already in the records you get your message and exit Sub

    Set it to ComboBox9 and Column "O" though and it just cant find the dates

    I wouldn't give up on it though. Clarify the format the dates are entered as and match the search to "see" the date format, or even easier "pick another column

    Have a look at attached it will give you an idea


    Edit : Your format of dates in your combobox9 droplist was the problem. Sorted but use a single date format throughout for ease
    Attached Files Attached Files
    Last edited by nigelog; 12-20-2018 at 11:49 AM.

  3. #3
    Registered User
    Join Date
    01-07-2019
    Location
    turkey
    MS-Off Ver
    office 365 proplus
    Posts
    7

    Re: Check duplicate from userform values before pasting to worksheet VBA

    I have a basic userform for inventory. but I have a small problem with record barcode. If I record second time the same barcode,I want to see alert message in my userform.
    I could not resolve this problem. my barcodes has 30 digit. Can u help me for my problem.
    UserID : Report
    Password : 9876
    Attached Files Attached Files
    Last edited by ebademci; 01-07-2019 at 04:30 AM.

  4. #4
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,293

    Re: Check duplicate from userform values before pasting to worksheet VBA

    @ebademci

    This is an old thread and you are required to post your question in a new thread

  5. #5
    Registered User
    Join Date
    01-07-2019
    Location
    turkey
    MS-Off Ver
    office 365 proplus
    Posts
    7

    Re: Check duplicate from userform values before pasting to worksheet VBA

    I could not find any solution for my problem. Can you help me where I can find ?

  6. #6
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,293

    Re: Check duplicate from userform values before pasting to worksheet VBA

    Please Login or Register  to view this content.
    Last edited by nigelog; 01-07-2019 at 09:26 AM.

  7. #7
    Registered User
    Join Date
    01-07-2019
    Location
    turkey
    MS-Off Ver
    office 365 proplus
    Posts
    7

    Re: Check duplicate from userform values before pasting to worksheet VBA

    ıt didnt work in my userform because of barcode digits. my barcode has 30 digit.
    do u have another solution?

  8. #8
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,293

    Re: Check duplicate from userform values before pasting to worksheet VBA

    How are your 30 digit barcodes formatted as text??

  9. #9
    Registered User
    Join Date
    01-07-2019
    Location
    turkey
    MS-Off Ver
    office 365 proplus
    Posts
    7

    Re: Check duplicate from userform values before pasting to worksheet VBA

    Sorry. My barcode format is like "343009890000188999009". 21 digit.

  10. #10
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,293

    Re: Check duplicate from userform values before pasting to worksheet VBA

    If I enter that as a number in worksheet I get 2.4E+20 (excel converted it)
    So are they stored as text or some other format

  11. #11
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,293

    Re: Check duplicate from userform values before pasting to worksheet VBA

    This works for me here with any length of text formatted numbers
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    01-07-2019
    Location
    turkey
    MS-Off Ver
    office 365 proplus
    Posts
    7

    Re: Check duplicate from userform values before pasting to worksheet VBA

    Did you try this code in my excel files?
    I tried but it didnt work.

  13. #13
    Valued Forum Contributor dotchiejack's Avatar
    Join Date
    05-21-2015
    Location
    Antwerp,Belgium
    MS-Off Ver
    2016
    Posts
    507

    Re: Check duplicate from userform values before pasting to worksheet VBA

    I tried but it didnt work.
    I tested it and it works perfectly.
    Did you adjust the sheet names?
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Click the * Add Reputation below to say thanks.

  14. #14
    Registered User
    Join Date
    01-07-2019
    Location
    turkey
    MS-Off Ver
    office 365 proplus
    Posts
    7

    Re: Check duplicate from userform values before pasting to worksheet VBA

    can you add your codes and attach my excelfile here?

+ 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] Check if entry on userform is not a duplicate before pasting on the worksheet
    By rakotonirinas in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-19-2018, 12:35 PM
  2. [SOLVED] Copy a row, check table for duplicate, give option to overwrite duplicate before pasting
    By Frankie_The_Flyer in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-11-2017, 09:56 PM
  3. Replies: 4
    Last Post: 08-21-2015, 03:59 PM
  4. Userform to check 2 textboxes for duplicate & date check
    By LadyAlina in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-24-2015, 09:26 AM
  5. Userform VBA to check 2 columns (A & B) for duplicate entries
    By stevebailey in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-24-2014, 04:27 AM
  6. Check for duplicate values within the same worksheet
    By aashishd233 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-16-2013, 03:34 PM
  7. Userform - check for duplicate entries
    By glynnhicks in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-16-2013, 10:48 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