+ Reply to Thread
Results 1 to 17 of 17

userform textbox2 entry to copy paste into worksheet with a match (from textbox1) & offset

  1. #1
    Registered User
    Join Date
    06-16-2019
    Location
    Melbourne
    MS-Off Ver
    10
    Posts
    9

    userform textbox2 entry to copy paste into worksheet with a match (from textbox1) & offset

    I am a basic VBA user and require:
    userform textbox2 entry to copy paste into worksheet with a match (from textbox1) & offset

    I've failed below trying a lookup so feel a match would assist here?
    Please Login or Register  to view this content.
    Thanks everyone.
    Last edited by EmXLS; 06-19-2019 at 12:27 AM. Reason: Adding file

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: userform textbox2 entry to copy paste into worksheet with a match (from textbox1) & of

    You just have it backwards. You are trying to copy the contents from textbox2 to the lookup value. That's illegal.

    If I understand what you want, try this:
    Please Login or Register  to view this content.
    If I've misunderstood please give a more complete description of what you want to do. Remember we can't see your file or userform. Also you can attach the file to make it clearer.

    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #2 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,527

    Re: userform textbox2 entry to copy paste into worksheet with a match (from textbox1) & of

    Or maybe
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    06-16-2019
    Location
    Melbourne
    MS-Off Ver
    10
    Posts
    9

    Re: userform textbox2 entry to copy paste into worksheet with a match (from textbox1) & of

    Thank you both for your prompt replies and support as a new user. I have now attached my file to assist.

    My aim is to paste the hand-keyed entry in TextBoxAMEdit, into Sheet1 column J when ID key Sheet1 column A matches TextBoxID
    Last edited by EmXLS; 06-19-2019 at 12:35 AM. Reason: Clarifying with file attachment

  5. #5
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,527

    Re: userform textbox2 entry to copy paste into worksheet with a match (from textbox1) & of

    Please Login or Register  to view this content.
    If I understand your naming right, you need to change following
    TextBox1 = TextBoxID
    TextBox2 = TextBoxAMEdit
    TextBox1 has the data to look for in Column A
    TextBox2 has the data that will be placed in Column J in the same Row where the data in Column A was found.

    Note: Data entered in TextBox1 has to be identical to the data to be searched for in Column A.
    One of the common problems is that sometimes data has leading or trailing spaces which makes it different.
    Last edited by jolivanes; 06-19-2019 at 01:19 AM. Reason: extra info

  6. #6
    Registered User
    Join Date
    06-16-2019
    Location
    Melbourne
    MS-Off Ver
    10
    Posts
    9

    Re: userform textbox2 entry to copy paste into worksheet with a match (from textbox1) & of

    Hi jolivanes

    I'm just missing how 2 final concepts can be used with the successfull code you provided.
    If TextBox2 has a blank/no entry, then dont want to paste the blank, leave the original data in column J.
    Want to hide sheet1

    Please Login or Register  to view this content.
    Thanks for this final assistance.

  7. #7
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,527

    Re: userform textbox2 entry to copy paste into worksheet with a match (from textbox1) & of

    Change TextBox Names as required again
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    06-16-2019
    Location
    Melbourne
    MS-Off Ver
    10
    Posts
    9

    Re: userform textbox2 entry to copy paste into worksheet with a match (from textbox1) & of

    Thank you so much for the clarity here.
    It "sometimes" works.
    Two errors can appear;
    could not set the value property. type mismatch
    or
    object variable or With block variable not set

    Have uploaded my current file version with all of your coding for reference if needed.
    I appreciate your help.
    Attached Files Attached Files

  9. #9
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,527

    Re: userform textbox2 entry to copy paste into worksheet with a match (from textbox1) & of

    Please Login or Register  to view this content.
    Why is above in both the code windows of Sheet1 and ShiftPopup (=UserForm)?

    What is this suppose to do? I have never seen this before.
    Please Login or Register  to view this content.
    Your best bet might be to explain exactly what you want to achieve. I find it very difficult to fix code that I can't run

  10. #10
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: userform textbox2 entry to copy paste into worksheet with a match (from textbox1) & of

    Quote Originally Posted by jolivanes View Post
    Please Login or Register  to view this content.
    Why is above in both the code windows of Sheet1 and ShiftPopup (=UserForm)?
    It will have absolutely no effect in the UserForm code. It looks like a mistake.

    What is this suppose to do? I have never seen this before.
    Please Login or Register  to view this content.
    It creates a string from the value in column A of the active cell's row, the value in row 3 of the active cell's column, and the value in column B of the active cell's row, and separates the three values with the "|" character.

  11. #11
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,527

    Re: userform textbox2 entry to copy paste into worksheet with a match (from textbox1) & of

    Thanks 6StringJazzer
    Cute way of doing that. Never too old to learn and see new things.

  12. #12
    Registered User
    Join Date
    06-16-2019
    Location
    Melbourne
    MS-Off Ver
    10
    Posts
    9

    Re: userform textbox2 entry to copy paste into worksheet with a match (from textbox1) & of

    Thank you both 6StringJazzer & jolivanes.

    The "|" is just how the business define/concatenate an ID of unique products. I am assuming cute means a strange way (lol)... you may notice that I seem to be applying my excel formula methods to VBA as a newbie. May be looking like strange coding to you, so I appreciate your help so much!
    1) have removed the double-up of the double-click
    2) error still present: object variable or With block variable not set
    3) debug points to---------> .Find

    Please Login or Register  to view this content.
    You guys are awesome!

  13. #13
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,527

    Re: userform textbox2 entry to copy paste into worksheet with a match (from textbox1) & of

    Is Sheet1 Visible when you run the macro?
    Is the exact Text (Value) of TextBoxID in Column A of Sheet1? No extra leading or trailing spaces?

  14. #14
    Registered User
    Join Date
    06-16-2019
    Location
    Melbourne
    MS-Off Ver
    10
    Posts
    9

    Re: userform textbox2 entry to copy paste into worksheet with a match (from textbox1) & of

    The error is present if Sheet1 is hidden or visible.
    I have just found the trigger for the error If Sheet1 has filters with selected data, the error appears.

  15. #15
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,527

    Re: userform textbox2 entry to copy paste into worksheet with a match (from textbox1) & of

    OK, you found your problem and you're rectifying it I assume.
    I was going to post the following so I will anyway.

    If you change the code to this, what is the result?
    Please Login or Register  to view this content.
    Note: Check references and change where/if required because I ran this on a test book

    BTW, this would be my preference but to each his own. Many ways lead to Rome.
    Please Login or Register  to view this content.
    Last edited by jolivanes; 06-21-2019 at 12:21 AM.

  16. #16
    Registered User
    Join Date
    06-16-2019
    Location
    Melbourne
    MS-Off Ver
    10
    Posts
    9

    Re: userform textbox2 entry to copy paste into worksheet with a match (from textbox1) & of

    Thank you for this additional code. But, I realise this solution is probably not in the right location of code. Because the userform uses data in Sheet 1, it errors before it can "show" because it can't populate the userform information anyway.
    I have pinpointed the exact problem which you raised before: what to do if the exact text is not in Column A? I believe (with my little experience), the solution will be best placed in the double-click function, whereby if the active cell the user is double-clicking is "0" then a message box needs to alert and the userform doesn't even show. This is the last error I hope.

    Please Login or Register  to view this content.
    This forum and you guys are the best!

  17. #17
    Registered User
    Join Date
    06-16-2019
    Location
    Melbourne
    MS-Off Ver
    10
    Posts
    9

    Re: userform textbox2 entry to copy paste into worksheet with a match (from textbox1) & of

    I'm hoping for assistance on this final step
    Please, from anyone

+ 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] if textbox1 and textbox2 shows a match then output will be on textbox3,4,5
    By serenitylai in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 03-26-2017, 12:07 PM
  2. How to minus textbox1.value from textbox2.value userform
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-10-2017, 07:55 AM
  3. Replies: 1
    Last Post: 01-30-2017, 05:54 PM
  4. [SOLVED] Userform - User enters date into Textbox1, want Textbox2 to return a date based on formula
    By Quasis in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-30-2017, 01:06 PM
  5. [SOLVED] Sort by name Userform.....Textbox1, Textbox2, Textbox3, Textbox4
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-01-2014, 07:53 AM
  6. [SOLVED] Textbox1 's value Copy to textbox2, textbox3, textbox4, textbox5 Solved by : Sixthsense
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-25-2014, 05:35 AM
  7. [SOLVED] Userform Textbox1 = Val(Textbox2.Value) / 2
    By Excelnoub in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-14-2013, 09:37 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