+ Reply to Thread
Results 1 to 11 of 11

Finding and copying data from one sheet to another

  1. #1
    Registered User
    Join Date
    11-11-2007
    Posts
    7

    Finding and copying data from one sheet to another

    Hi everyone,

    I'm new to the forum and new to VBA as well, so I really hope that I could receive good advice and help here from seasoned/experienced programmers.

    If you refer to the attachment, basically what I am trying to do is to retrieve information from 'ClientDB' and plucking some of those data into 'UpdateClient'. However, I don't know how to write any code to read the cell-link and trigger a macro for the correct company. When I tried to record a macro, what I did was to copy and paste data from 'UpdateClient' into row16 of 'ClientDB'. But this is terribly flawed cos it doesn't lookup the correct client in ClientDB and effectively wipes out some other client's details.

    Is there a way to rectify this and could anyone help, perchance? thanks in advance!!!

    sab
    Attached Files Attached Files

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    The attached might help. I'm afraid that I mucked up your data base with testing values.

    The routine UpdateMaybe should be linked to the Update button on UpdateClient. It finds the client row from the index of the dropdown. Since the dropdown is loaded from the ClientDB, the restoration should match. I couldn't find Departments or Client ID's on the sheet ClientDB.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    11-11-2007
    Posts
    7
    thank you sooo much mike!! it was greatly appreciated it worked like a charm!!!

    but i have another problem though. I was trying to follow your code to update order details but I'm not sure how to tweak the code properly!

    can someone please correct me?

    Please Login or Register  to view this content.
    many thanks,
    sab
    Attached Files Attached Files
    Last edited by mikerickson; 11-12-2007 at 01:37 PM.

  4. #4
    Registered User
    Join Date
    11-11-2007
    Posts
    7
    would anyone be able to help?

  5. #5
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    Code preserves its indending and is easier to read if one wraps one's code. (Hence the site's rule.) Please do so.

    This line is a problem.
    Please Login or Register  to view this content.
    In the first file, I was reading the ListIndex of the ComboBox to get the row number.
    But Text boxes don't have indices and Forms menu textboxes aren't controls (no Control Format).
    To get the contents of Text Box 17, this syntax would be used
    Please Login or Register  to view this content.
    Its not clear what is supposed to be in that text box, it looks like you are using it as a command button.

    You may want to use find the row number with,
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    11-11-2007
    Posts
    7
    hi mike, thanks for your response!!

    i wanted to wrap the code but i didn't know how.... i missed the button and only saw the quote button sorry!

    anyway, it's not working for me somehow

    what i have is this:

    Please Login or Register  to view this content.
    it says the bug is in the new line I added in:

    Please Login or Register  to view this content.
    yikesss :S


    -sab

  7. #7
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    The code you added in refers to the entry in the text box. It doesn't do anything with that value. Is as if you added the line
    Please Login or Register  to view this content.
    .
    What happens if you omit that line, but retain the
    Please Login or Register  to view this content.
    ?

  8. #8
    Registered User
    Join Date
    11-11-2007
    Posts
    7
    yikes mike, nothing happens!!!

  9. #9
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    The routine I posted was to get data from UpdateClient and put it in ClientDB.

    Your modification is trying to move data from Update Job and move it to Job List. The cells references have to be changed to match the new task.

  10. #10
    Registered User
    Join Date
    11-11-2007
    Posts
    7
    hi mike,

    i did change the cell ref but have no idea why nothing is happening!

    can i just clarify..

    If I am moving from "Update Job" to "Job List", then clientrow is "Update Job" and toSheet is "Job List" right?

    so

    Please Login or Register  to view this content.
    means shifting the data from cell (row 22, column 3) from "Update Job" to column 1 of "Job List"?

  11. #11
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    Yes, that's the right interpetattion of the syntax.

    You might want to put
    Please Login or Register  to view this content.
    in the routine to find out if its working right.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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