Finding certain words in a cell and return a value based off the word found.
Solved/Closed
shanej69
Posts
1
Registration date
Sunday July 25, 2021
Status
Member
Last seen
July 25, 2021
-
Jul 25, 2021 at 06:17 PM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen January 16, 2023 - Jul 26, 2021 at 11:37 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen January 16, 2023 - Jul 26, 2021 at 11:37 AM
Related:
- Find a word in a cell and return value
- If cell contains text then return value multiple conditions ✓ - Excel Forum
- Word free for u - Guide
- If cell contains date then return value ✓ - Office Software Forum
- Based on the values in cells b77:b81, what function can automatically return the value in cell c77? ✓ - Excel Forum
- Vim find word - Guide
1 response
TrowaD
Posts
2921
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
January 16, 2023
549
Jul 26, 2021 at 11:37 AM
Jul 26, 2021 at 11:37 AM
Hi Shanj69,
Your example shows a pattern, column B shows the first letter of the text in column A. This can be achieved by using the following formula:
=LEFT(A2,1)
Drag the formula down for the rest of the cells.
If this is not on purpose, then you can use a nested IF formula like:
=IF(A2="Apple","A",IF(A2="Banana","B",""))
Or add to this code:
Best regards,
Trowa
Your example shows a pattern, column B shows the first letter of the text in column A. This can be achieved by using the following formula:
=LEFT(A2,1)
Drag the formula down for the rest of the cells.
If this is not on purpose, then you can use a nested IF formula like:
=IF(A2="Apple","A",IF(A2="Banana","B",""))
Or add to this code:
Sub RunMe() For Each cell In Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row) If cell.Value = "Apple" Then cell.Offset(0, 1).Value = "A" If cell.Value = "Banana" Then cell.Offset(0, 1).Value = "B" Next cell End Sub
Best regards,
Trowa