populate values in col C based on values contains in B

aravindhan_31

Well-known Member
Joined
Apr 11, 2006
Messages
672
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Thanks for helping me so many days, I need ur help again...
I have 3 columns in my excel sheet,
Col A( Data)
Col B ( Invoice Description)
Col C( Result)

I have date and Invoice description column filled with data, I need to filter Column B> custom filter> contains > "Dup" and enter value as "Twice" in Column C.
again i customer filter> contains > " Canteen" then enter value in Column C as "Tea"
similarly i have 45 conditions and the number of rows are not fixed, I would appreciate very much if someone could help me to build a code with case function i can add all those conditions:

few Eg:
If values in Column B contains :"uncash" then in C column it should populate Credit in the respective rows
If values in Column B contains :"Dup" then in C column it should populate Twice in the respective rows
If values in Column B contains :"bug" then in C column it should populate Wow in the respective rows
If values in Column B contains :"RQ" then in C column it should populate Pay by Check in the respective rows
If values in Column B contains :"AP13" then in C column it should populate Payment in the respective rows
If values in Column B contains :"Canteen" then in C column it should populate Tea in the respective rows OF
If values in Column B contains :"RSV" then in C column it should populate Bus in the respective rows

Thanks for you help
The cross post is here: http://www.excelforum.com/excel-pro...ased-on-values-contains-in-b.html#post2216736
Arvind
 
Last edited:

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Code:
Sub IdData()
Dim LastRow As Long

    Application.ScreenUpdating = False
    
    With ActiveSheet
    
        LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
        
        Call UpdateData("uncash", "Credit", LastRow)
        Call UpdateData("dup", "Twice", LastRow)
        'etc
    End With
    
    Application.ScreenUpdating = True
End Sub

Private Sub UpdateData(LookFor As String, Replacement As String, LastRow As Long)

    With ActiveSheet
    
        .Range("B1").AutoFilter Field:=1, Criteria1:="=*" & LookFor & "*", Operator:=xlAnd
        .Range("C2").Resize(LastRow - 1).Value = Replacement
        .Range("B1").AutoFilter
    End With
End Sub
 
Upvote 0
Hi,

Thanks for your help,

I am getting "Twice" as result for all the values"

Please help me on this

Arvind
 
Upvote 0
Upvote 0
Hello jonmo,

would appreciate verymuch if you could explain this formula to me for my learning...

I could not find what is 2^ 15 here
 
Upvote 0

Forum statistics

Threads
1,216,124
Messages
6,128,993
Members
449,480
Latest member
yesitisasport

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top