VBA to match value in one column to another and paste adjacent value

  • Re: VBA to match value in one column to another and paste adjacent value


    Quote from PCI;772134

    What about a formula like
    G6 = IF(O6=B6,P6,"")



    Most days I will have multiple entries for some stations. I'm just trying to get the first one in without keying it and follow up by keying any other amounts for that station that day. I can't use a formula (like SUMIF), as the cells need to show what the values are composed of so the users who take it from there can see the amounts of the individual transactions (=2500.25+1612.00+53.50) for the work they have to do after I fill it in.

  • Re: VBA to match value in one column to another and paste adjacent value


    It means you don't need to copy the value from column "O" to "G" but the formula from column "O" with the same references.
    Is it what you need ...? So far there is no formula today in column "O"

    Triumph without peril brings no glory: Just try

  • Re: VBA to match value in one column to another and paste adjacent value


    Each day I begin by pasting two columns of data in columns O and B. I'm just trying to get the data in column O over to column G by matching the station call letters. I realize that if one station has two entries in column O on a particular day, that only one of them with go into column G. I will have to later edit the cell in col G to add the amount that did not go when the macro ran.


    You gave me this code a couple of months ago that compares stations and amounts to a list of station and amounts, then copies any amounts that match both criteria to specific column/row. What I hoped for this time was to just compare col O to col B and when they match, copy the adjacent value from column P to column G. Perhaps it would just be a case of modifying this code?


  • Re: VBA to match value in one column to another and paste adjacent value


    "If the station in col O matches the station in col B, paste the adjacent value from column P into the corresponding cell in col G."
    Do we need to clear the value in column P when it has been added into column G ?

    Triumph without peril brings no glory: Just try

  • Re: VBA to match value in one column to another and paste adjacent value


    Is it what you need ??
    Try and comment

    Triumph without peril brings no glory: Just try

  • Re: VBA to match value in one column to another and paste adjacent value


    Quote from PCI;772358

    "If the station in col O matches the station in col B, paste the adjacent value from column P into the corresponding cell in col G."
    Do we need to clear the value in column P when it has been added into column G ?


    I ran the code and it works great. It would be awesome if the value in column P was cleared after it was added to column G, as I could immediately see which amounts were left for me to enter manually. Otherwise, I will need to review the paper version of the document and cross off the ones that placed in order to determine which ones I need to enter manually.

  • Re: VBA to match value in one column to another and paste adjacent value


    Take care today macro does not add the value from column "P" to column "G", it replaces the value and today column "G" is empty:
    Do we need to add column "G" with column "P" value ?

    Triumph without peril brings no glory: Just try

  • Re: VBA to match value in one column to another and paste adjacent value


    Here another one
    Column "G" value is added with column "P" value

    Triumph without peril brings no glory: Just try

  • Re: VBA to match value in one column to another and paste adjacent value


    Quote from PCI;772362

    Take care today macro does not add the value from column "P" to column "G", it replaces the value and today column "G" is empty:
    Do we need to add column "G" with column "P" value ?


    The code you just gave me is fantastic. Yes, it would be wonderful if there was a way to add the second instance of an amount to the first in column G, but the result would always have to show the individual amounts in the cell with a "+" between them, i.e. "=2500+1540" instead of the total of 4,040. If that's not possible, no problem. I am grateful for what you have given me.

  • Re: VBA to match value in one column to another and paste adjacent value


    See here next code: Check and double check

    Triumph without peril brings no glory: Just try

  • Re: VBA to match value in one column to another and paste adjacent value


    Here a remake to avoid any possible issue with the Station

    Triumph without peril brings no glory: Just try

  • Re: VBA to match value in one column to another and paste adjacent value



    Runtime error '91'
    Object Variable or With block variable not set



    It gave me this error when it got to WYMT in column B. There is no deposit for WYMT this particular day, so is not listed in column O. I wonder if that is an issue?



    When I pressed Debug this is the line that was highlighted:


    Code
    If ((Not F Is Nothing) And (Cells(F.Row, CCCol2) <> "")) Then
  • Re: VBA to match value in one column to another and paste adjacent value


    See next code

    Triumph without peril brings no glory: Just try

  • Re: VBA to match value in one column to another and paste adjacent value


    This code ran without error, but did not add the additional values to the cells.

  • Re: VBA to match value in one column to another and paste adjacent value


    Can you send a sample of the file with the issue.
    If there is no value in column"O" there is nothing to add ...no?

    Triumph without peril brings no glory: Just try

  • Re: VBA to match value in one column to another and paste adjacent value


    Clear now,
    Yes it was not supposed to have several times the same Station in column "G".
    There is a solution on preparation

    Triumph without peril brings no glory: Just try

  • Re: VBA to match value in one column to another and paste adjacent value


    Here we are:check, check, check again ...!

    Triumph without peril brings no glory: Just try

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!