+ Reply to Thread
Results 1 to 4 of 4

Macro to find duplicate value and replace adjacent cell with different value

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Macro to find duplicate value and replace adjacent cell with different value

    Hi.

    I have a range of different fruits and their respective costs and one of the fruits, we'll use "Apple and crabapple", the price went up. I would like to update the cost of this fruit by choosing "Apple and crabapple" from a drop down list (which I use from data validation) entering the new cost in the adjacent cell and hitting a macro button that will update the cost of this fruit from the range. I would like the macro to find the duplicate value of "Apple and crabapple" and replace the cost with the new cost.
    Please see this attachment Fruits.xlsm

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro to find duplicate value and replace adjacent cell with different value

    Maybe:

    Sub kosherboywww()
    Dim i As Long
    For i = Range("A" & Rows.count).End(3)(1).Row To 2 Step -1
        If Range("A" & i).Value = Range("F4").Value Then
            Range("B" & i).Value = Range("H4").Value
        End If
    Next i
    End Sub

  3. #3
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Re: Macro to find duplicate value and replace adjacent cell with different value

    Thank you! Your code is short and to the point and it worked like a charm!

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro to find duplicate value and replace adjacent cell with different value

    You're welcome. Glad to help out and thanks for the feedback.

+ 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. Macro to compare text in ranges to find match and replace with adjacent value.
    By 54ed in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-11-2013, 06:44 PM
  2. Macro to find all specific values in column and replace adjacent cell values
    By dblock02 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-23-2013, 06:03 AM
  3. Find String and Replace With Adjacent Cell
    By Steve0492 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-29-2012, 05:19 PM
  4. Replies: 1
    Last Post: 01-26-2012, 10:06 AM
  5. Find, Replace with and then replace adjacent cell
    By Craig2097 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-18-2009, 12:42 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