help with this code for assigning a value to a cell when another cell contains a specific string value

kbishop94

Active Member
Joined
Dec 5, 2016
Messages
476
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Column P (16) contains 'codes' that represent a description of something. Example: "CSR2B" = wrong labels

Also there can be more than 1 code in each cell in column P (and almost always will be more than 1 actually.) (which is whY I am using the 'Like' operator and the '& vbCrLf' )

For the most part, I have it figured out how I need it to work, but my code isnt quite structured/written correctly and I keep getting errors no matter how I seem to arrange it...

Heres what I have:
Code:
For Each Cell In Range(Cells(4, 16), Cells(rRow, 16))
If Cell Like "*CSR2B*" Then Rows(Cell, "A").Value = "wrong label " & vbCrLf
Next

I am using the "like" and vbCrLf because,again, most of all the cells in column P will have multiple ones.

The code needs to place the new value in column A in the same row.

Here is the how the 'codes' appear on the worksheet:

8xv9cl.jpg



Here is what I need it to look like in column "A" per the corresponding "code" ("CSR2B") found in column P:
(where CSR0o = "paper work or billing issue" and CSR2B = "wrong labels")
5v83kw.jpg
 
Last edited:

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Try
Code:
If Cell Like "*CSR2B*" Then Cells(Cell.Row, "A").Value = "wrong label " & vbCrLf
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

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