+ Reply to Thread
Results 1 to 12 of 12

VBA - value is not pasting in master sheet

  1. #1
    Forum Contributor
    Join Date
    07-08-2010
    Location
    ireland
    MS-Off Ver
    Excel 2007
    Posts
    121

    VBA - value is not pasting in master sheet

    Hi All,

    I have userform to lookup for a value in "Database". If value found, then return values and paste into another sheet "IQuery". however, if value not found in "Database", then let the user to add empty fields.

    After pressing add button, new data shall be saved in both sheet in the last available row. My VBA code is as follows. However i have attached a sample sheet for your test.

    Please Login or Register  to view this content.
    Issue i am facing is that new values are not adding in the "database", its only adding in one sheet. Can anyone help me to fix it please

    Regards

    Template-Vlookup-Userform-in-Code.xls

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA - value is not pasting in master sheet

    Hi shido

    Try this.
    Please Login or Register  to view this content.
    Last edited by jaslake; 10-12-2015 at 05:33 PM.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Forum Contributor
    Join Date
    07-08-2010
    Location
    ireland
    MS-Off Ver
    Excel 2007
    Posts
    121

    Re: VBA - value is not pasting in master sheet

    Hi John,

    Thanks for your time. Above code is only adding value in both sheets. I would also need to lookup ID in the "Database" and return the associated value if found.

    Would you please mind if you fix above

    1. lookup ID value in the "database" sheet, if found then paste it in the "IQuery" sheet.

    2. if lookup ID is not found, then let the user add new data in "database" and "IQuery" sheet (as above)

    Kind Regards,
    Last edited by shido; 10-12-2015 at 06:01 PM.

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA - value is not pasting in master sheet

    Hi shido

    I think I see what you're trying to do...I'll look at it.

  5. #5
    Forum Contributor
    Join Date
    07-08-2010
    Location
    ireland
    MS-Off Ver
    Excel 2007
    Posts
    121

    Re: VBA - value is not pasting in master sheet

    Great.. Thanks.. looking forward to it

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA - value is not pasting in master sheet

    Hi shido

    You have multiple same ID's in Sheet IQuery (for example...1002, 1007, 1009). Why? What's the purpose of Sheet IQuery...to track changes?

    I'd assume Sheet Database ID's should all be unique.

    Please explain further what your end goal is.

  7. #7
    Forum Contributor
    Join Date
    07-08-2010
    Location
    ireland
    MS-Off Ver
    Excel 2007
    Posts
    121

    Re: VBA - value is not pasting in master sheet

    Hi John,

    I am actually using "database" for saving my actual data. I am then using "userform" to lookup if value is existed in the "Database". if the value is existed in the "database" then return it in "IQuery".

    I have separate VBA code which copy and clear IQuery rows and send it as email attachment. IQuery is used to save looked up values (can be multiple same IDs)

    Lets say, purpose of this code is to searching data existing data, adding new data and send it to the user (separate VBA code, not included but works okay).

    I hope i have answered your question.
    Last edited by shido; 10-13-2015 at 04:42 AM.

  8. #8
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA - value is not pasting in master sheet

    Hi shido

    If I understand the issue, try this Code in the attached...
    Please Login or Register  to view this content.
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    07-08-2010
    Location
    ireland
    MS-Off Ver
    Excel 2007
    Posts
    121

    Re: VBA - value is not pasting in master sheet

    Its perfect. This is exactly what i wanted. However, a minor addition, if you please do not mind to look into it.

    Database tab: Along with adding new data, I would also like to copy formatting from previous row and convert ID to number. Currently, it is saving ID as text as seen in the following pic

    lookup.jpg

    Regards,
    Last edited by shido; 10-13-2015 at 03:36 PM.

  10. #10
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA - value is not pasting in master sheet

    Hi shido

    Replace the Command Button Click Code with this...
    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    07-08-2010
    Location
    ireland
    MS-Off Ver
    Excel 2007
    Posts
    121

    Re: VBA - value is not pasting in master sheet

    Perfect,

    Thanks for your help John. i really appreciate your time.

  12. #12
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA - value is not pasting in master sheet

    You're welcome...glad I could help. Thanks for the Rep.

+ 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] Master sheet to split sheets back to another master sheet
    By FurRelKT in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-24-2017, 02:08 PM
  2. Copying/Pasting Data from All Files in Folder to Master Sheet According to Headers
    By sdwhiteh in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-22-2015, 01:23 PM
  3. Replies: 1
    Last Post: 09-15-2014, 01:03 PM
  4. Replies: 3
    Last Post: 09-17-2013, 12:57 PM
  5. Select all sheet copy paste as value & except Master 1 & Master 2
    By tek9step in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-29-2010, 06:49 AM
  6. Pasting data from a master file to two other files
    By Bob@Sun in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-17-2009, 02:50 PM
  7. Copy and pasting specific sheet data to a master worksheet
    By simora in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-09-2005, 01:06 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