If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > VBA Excel Macro to replace cell value in the column 3 based on another column conditi

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
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
Reply With Quote
  #2 (permalink)  
Old
Registered User
 
Join Date: Apr 2004
Location: Derbyshire, UK
Posts: 747
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
Reply With Quote
  #3 (permalink)  
Old
Registered User
 
Join Date: Jun 2012
Posts: 4
Works like a charm. Thanks MTB for taking a moment to help a rookie out.

Cheers,

KW
Reply With Quote
Reply

Tags
excel, vba

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On