+ Reply to Thread
Results 1 to 17 of 17

Match data on source and destination sheet and change value

  1. #1
    Registered User
    Join Date
    06-06-2013
    Location
    Cambridge,England
    MS-Off Ver
    Excel 2010
    Posts
    15

    Match data on source and destination sheet and change value

    I have extracted data from multiple sheets and now want to mark this data as "Paid" and for the macro to go back and change the value in the original sheet on a row in column "AR" to "PAID.
    All the columns have the same data type in.

    The extracted data contains the original sheet name and each row has a unique ID No to it.

    I know I probably need to use INDEX and MATCH and then Offset to post value.

    Attached worksheet shows the data and columns.

    Thanks
    DK
    Attached Files Attached Files

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Match data on source and destination sheet and change value

    Hi, Cammandk,

    maybe you should consider to attach a sample of sheet SCH7 to see which columns you refer to.

    A sample for this which may need amendment as I assumed the same Columns for each may look like
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    06-06-2013
    Location
    Cambridge,England
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Match data on source and destination sheet and change value

    Hi Holger

    Sorry for the delay in responding to your reply.
    I've looked at it and think I understand what it should be doing. There are a couple of changes in my version now where COL Sheet will = "D" and Col ID will = "E".
    Also my first "Paid" line now starts at "W6". I have made these changes to your code.
    When I run it or step through the code nothing seems to happen at all.

    DK

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Match data on source and destination sheet and change value

    Hi, DK ,

    consider to attach a sample workbook to have a look at. "PAID" from your first post differs "Paid" from your second which might be a reason why the code would skip the lines.

    Ciao,
    Holger

  5. #5
    Registered User
    Join Date
    06-06-2013
    Location
    Cambridge,England
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Match data on source and destination sheet and change value

    Hi Holger

    I've attached a new sheet that shows SCH6 which contains the original data.
    I have a macro that extracts this to the AP sheet as shown.

    Your code was to work backwards and but the text PAID in COL AR of the original data row. I tried using PAID and this
    still did not work.

    What I really need is instead of putting PAID against the line in the AP sheet is to put a date - say 24-Mar-14
    and for this ddate to then be put in COL AR of the original data row so that this can be used to work with a cashflow sheet.

    Hope you can help as this is final part of my jigsaw.

    Thanks for looking at.

    DK.
    Attached Files Attached Files

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Match data on source and destination sheet and change value

    Hi, Cammandk,

    there were some minor blinks with the code but it´s your data on the sheets that gives no matches...

    Please Login or Register  to view this content.
    Ciao,
    Holger

  7. #7
    Registered User
    Join Date
    06-06-2013
    Location
    Cambridge,England
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Match data on source and destination sheet and change value

    Hi Holger

    Thanks for replying. I did have the correct D/E/I etc on the version that I tried and was using PAID in W6 but it was not finding anything in the rngFound.

    Could you explain what the code below does - I'm concerned when I see Worksheets.Add?

    Thanks
    DK


    If Not Evaluate("ISREF('" & .Cells(rngCell.Row, cstrCOL_SHEET).Value & "'!A1)") Then
    Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = .Cells(rngCell.Row, cstrCOL_SHEET).Value

  8. #8
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Match data on source and destination sheet and change value

    Hi, Cammandk,

    please remember to use code-tags when showing a part of a procedure here on ExcelForum.

    This bit will check if the sheet of a given name exists and if not will insert one and give this sheet th ename in order to let the code work smoothly (otherwise a run time error would be raised that the sheet doesn´t exist in the workbook).

    Ciao,
    Holger

  9. #9
    Registered User
    Join Date
    06-06-2013
    Location
    Cambridge,England
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Match data on source and destination sheet and change value

    Hi Holger
    Sorry about the tags - still finding my way around these forums.
    I understand why you might want the code to check that a sheet exists but I definately don't want the worksheet created if it doesn't. That should never be the case. Thats not part of the function of this code.
    Are you able to send back a working example based on my sheet as I still can't get it to register that there is a row in which column "W" has "PAID" in. Because of this the code stops.
    Thanks
    DK

  10. #10
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Match data on source and destination sheet and change value

    Hi, Cammandk,

    I thought that Column I needed to be compared also.

    Please Login or Register  to view this content.
    Ciao,
    HOlger

  11. #11
    Registered User
    Join Date
    06-06-2013
    Location
    Cambridge,England
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Match data on source and destination sheet and change value

    Hi Holger
    I'm travelling at the moment but tonight will send a new example that clearly shows and explains the data and actions needed.
    Your code will has the worksheet.add in which I don't need.
    The example will enable you to put your code in and see if it works.
    If it does then it can be uploaded again and I can look at it.
    Thank you for your efforts and patience.
    DK

  12. #12
    Registered User
    Join Date
    06-06-2013
    Location
    Cambridge,England
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Match data on source and destination sheet and change value

    Hi Holger

    I've attached a sample working sheet. The source data is in SCH5 and the extracted data is in AP.
    I've written in blue txt would has happened / how the sheets operate and what the code needs to be able to do.
    I've also written in AP what in the best of worlds I would like the code to be able to do.

    Hope you can help

    Many thanks
    DK
    Attached Files Attached Files

  13. #13
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Match data on source and destination sheet and change value

    Hi, Cammandk,

    you state that there is another macro copying over - I´m not so sure I´ve seen that before. In Sheet SCH5 Range E12:E24 you use an overcomplicated formula and format the result as text - any reason for that as I think that a normal addiition of the cell before would do as well and any result being displayed as standard would help with a macro. Last: any reason why you copy over the relative number of the record as opposed to copying over the row number directly?

    Ciao,
    Holger

  14. #14
    Registered User
    Join Date
    06-06-2013
    Location
    Cambridge,England
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Match data on source and destination sheet and change value

    Hi Holger

    When I state that I have another macro - I mean that the original source data is in SCH. I run an "Extract" Macro and it takes the data from Sch5 and puts it in Sheet AP. This all works well.
    The formula in E12-E24 was to create a unique id number for the line of information. In hindsight and as per your suggestion this would not be needed if the row number was captured and brought over to Sheet AP instead and then this could be used to go backwards and revise the ".PAID" update.


    My code and formula structures are probably not elegant as have only been dealing with vba for a few months and getting the result outweighs my knowledge of clean code.

    I am totally open to suggestions and am daily on a steep learning curve - so very happy for you to revise and provide a better solution

    Kind regards
    David

  15. #15
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Match data on source and destination sheet and change value

    Hi, David,

    I would simplify the sheets as neither the sheetname nor the number need to be placed on these sheets (information may be added when the records are being copied only to AP).

    Give this code a try:
    Please Login or Register  to view this content.
    Ciao,
    Holger

  16. #16
    Registered User
    Join Date
    06-06-2013
    Location
    Cambridge,England
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Match data on source and destination sheet and change value

    Hi Holger

    This didn't work at first but then I remembered your comments about the text fields so I changed them to general and it seemed to like it and is now working. Thank you.

    Two more things - As I mentioned previously what I ideally need is instead of "PAID" in COLW - that the user enters a real date and that that date for each line is taken back and put into SCH5 for instance.
    If this is too difficult then it would work using just 1 single date that would be found in "W4". Is this possible?

    For the original code you have provided you mentioned how the sheet and row no could be put into "AP" at the time of extraction. This would mean that the code that I have for this would need to be altered. This code is below - are you able to amend so that it does this?
    Not sure if I've done the code tags right?


    Please Login or Register  to view this content.

  17. #17
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Match data on source and destination sheet and change value

    Hi, David,

    as long as the date is always entered as a constant (not as a Formula) the basics can be kept only the logic needs to be changed (from a check of rngCell.Value being "PAID" to a check if IsDate(rngCell.Value)). When copying over you might need to format the cell value accordingly because otherwise the sequentiel number of the day would be placed.

    Please Login or Register  to view this content.
    I´d go away and use an unique identifier for each record in any sheet and use that. With what you have right now you would need to loop through the range of visible cells and copy each row over separately in order to get the row number.

    Ciao,
    Holger

+ 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. Populate Data from Source to Destination as shown
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 48
    Last Post: 02-22-2013, 06:17 PM
  2. Replies: 0
    Last Post: 11-05-2012, 03:30 PM
  3. how to copy (source sheet) a sheet going to another sheet (destination)
    By gerard_gonzales33 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 08-28-2012, 04:54 AM
  4. Get data from source workbook and paste to destination in change format
    By farrukh in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-03-2012, 01:47 AM
  5. copying and pasting from source sheet to destination sheet without naming source sht?
    By Simon Lloyd in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-02-2006, 01:15 PM

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