Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2012
    Posts
    4

    VBA Excel Macro to replace cell value in the column 3 based on another column conditi

    Hello,

    I really need some help. I need to change the existing cell Value in Column 1 where Column 6 meets the required condition.

    Example: My table range is (F69:K4323). Column F has a product model name and Column K is a Yes/No. What I would like to do is change the product model name for "Product 1" to "Product 1**********" if Column K = "yes"

    I hope it makes sense. Any help would be greatly appreciated.

    Thank you very much!

    P.S. I was able to find a way to make this work if Column K was actually Column A and Column F was Column B, But cant seem to make it fit my requirements

    Sub X()

    Dim rngData As Range
    Dim lngRow As Long

    Set rngData = Range("A1", Cells(Rows.Count, 1).End(xlUp))
    For lngRow = 1 To rngData.Rows.Count
    If UCase(rngData.Cells(lngRow, 1).Value) = "Yes" Then
    rngData.Cells(lngRow, 1).Offset(0, 1).Value = rngData.Cells(lngRow, 1).Offset(0, 1).Value & "************"
    End If
    Next
    End Sub

  2. #2
    Join Date
    Apr 2004
    Location
    Derbyshire, UK
    Posts
    755
    Hi

    I think I would do it something like this
    Code:
    Sub X()
        Dim lngRow As Long
        Dim BotRow As Long
        
        Cells(Rows.Count, "K").Select
        Selection.End(xlUp).Select
        BotRow = Selection.Row
        For lngRow = 1 To BotRow
            If UCase(Cells(lngRow, "K")) = "YES" Then
                Cells(lngRow, "F") = Cells(lngRow, "F") & "************"
            End If
        Next
    End Sub
    HTH


    MTB

  3. #3
    Join Date
    Jun 2012
    Posts
    4
    Works like a charm. Thanks MTB for taking a moment to help a rookie out.

    Cheers,

    KW

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •