How to re/name a cell if another cell contains X
Solved/Closed
Alexzandeur
Posts
3
Registration date
Thursday January 7, 2016
Status
Member
Last seen
January 8, 2016
-
Jan 7, 2016 at 07:44 AM
vcoolio Posts 1411 Registration date Thursday July 24, 2014 Status Moderator Last seen September 6, 2024 - Jan 8, 2016 at 03:14 PM
vcoolio Posts 1411 Registration date Thursday July 24, 2014 Status Moderator Last seen September 6, 2024 - Jan 8, 2016 at 03:14 PM
Related:
- If cell contains (multiple text criteria) then return (corresponding text criteria)
- If cell contains date then return value ✓ - Excel Forum
- Excel formula to check if cell contains a date - Excel Forum
- If cell A1 has text then cell B2 has today's Date ✓ - Excel Forum
- If cell contains multiple text how to add other cell value? ✓ - Excel Forum
- Based on the values in cells b77:b81, what function can automatically return the value in cell c77? ✓ - Excel Forum
3 responses
vcoolio
Posts
1411
Registration date
Thursday July 24, 2014
Status
Moderator
Last seen
September 6, 2024
262
Jan 8, 2016 at 06:15 AM
Jan 8, 2016 at 06:15 AM
Hello Alexzandeur,
Based on your above comment, I would say that the following should work for you:-
Following is a link to my test work book for you to peruse:-
https://www.dropbox.com/s/dbblligihczgt9v/Alexzandeur.xlsm?dl=0
Click on the button to see it work.
In Columns S & T, I've mixed up the upper and lower cases just to make sure that the code picks up on varying cases (and it does!).
You should be able to take it from here.
Cheerio,
vcoolio.
"if S2 contains "WALES" and T2 contains "YES" then change A2 to "YY" (Then cycle through rows)"
Based on your above comment, I would say that the following should work for you:-
Sub AllTheExs() Application.ScreenUpdating = False Dim lr As Long lr = Range("S" & Rows.Count).End(xlUp).Row For Each cell In Range("S2:S" & lr) If UCase(cell.Value) = "WALES" Then cell.Offset(, -18) = "XX" End If AllTheExsAndYs Next End Sub Sub AllTheExsAndYs() Dim lr As Long Dim i As Integer lr = Range("A" & Rows.Count).End(xlUp).Row For i = 2 To lr If UCase(Cells(i, 19).Value) = "WALES" And UCase(Cells(i, 20).Value) = "YES" Then Range(Cells(i, 1), Cells(i, 1)) = "YY" End If Next Application.ScreenUpdating = True End Sub
Following is a link to my test work book for you to peruse:-
https://www.dropbox.com/s/dbblligihczgt9v/Alexzandeur.xlsm?dl=0
Click on the button to see it work.
In Columns S & T, I've mixed up the upper and lower cases just to make sure that the code picks up on varying cases (and it does!).
You should be able to take it from here.
Cheerio,
vcoolio.
vcoolio
Posts
1411
Registration date
Thursday July 24, 2014
Status
Moderator
Last seen
September 6, 2024
262
Jan 7, 2016 at 10:46 PM
Jan 7, 2016 at 10:46 PM
Hello Alexzandeur,
Perhaps a simple "IF" formula is all that you need:-
=IF(S2="","",IF(S2="Wales","XX"))
Place the formula in cell A2 and drag it down as far as you need.
But if you still prefer a macro, then the following modified version of yours should do the task also:-
I hope that this helps.
Cheerio,
vcoolio.
Perhaps a simple "IF" formula is all that you need:-
=IF(S2="","",IF(S2="Wales","XX"))
Place the formula in cell A2 and drag it down as far as you need.
But if you still prefer a macro, then the following modified version of yours should do the task also:-
Sub AllTheExs() Application.ScreenUpdating = False Dim lr As Long lr = Range("S" & Rows.Count).End(xlUp).Row For Each cell In Range("S2:S" & lr) If UCase(cell.Value) = "WALES" Then cell.Offset(, -18) = "XX" End If Next Application.ScreenUpdating = True End Sub
I hope that this helps.
Cheerio,
vcoolio.
Alexzandeur
Posts
3
Registration date
Thursday January 7, 2016
Status
Member
Last seen
January 8, 2016
Jan 8, 2016 at 03:22 AM
Jan 8, 2016 at 03:22 AM
Thanks Vcoolio this works exactly as hoped. The only issue I'm having now is if I wanted to look at multiple conditions like if S2 contains "WALES" and T2 contains "YES" then change A2 to "YY" (Then cycle through rows)
I can manage to make it do it by looking at specific cells but can't get it to cycle through each one and change the A column accordingly, my version will look at T2 and then apply that to every cell in A column.
Sorry to be a pain but once I have the next step I should be able to duplicate it for any column I need.
The help is very much appreciated.
Thanks,
I can manage to make it do it by looking at specific cells but can't get it to cycle through each one and change the A column accordingly, my version will look at T2 and then apply that to every cell in A column.
Sorry to be a pain but once I have the next step I should be able to duplicate it for any column I need.
The help is very much appreciated.
Thanks,
vcoolio
Posts
1411
Registration date
Thursday July 24, 2014
Status
Moderator
Last seen
September 6, 2024
262
Jan 8, 2016 at 03:14 PM
Jan 8, 2016 at 03:14 PM
Hello Alexzandeur,
That's excellent! I'm glad that I was able to help.
Cheerio,
vcoolio.
That's excellent! I'm glad that I was able to help.
Cheerio,
vcoolio.
Jan 8, 2016 at 09:39 AM
Used your extras and have managed to duplicate it to look at dozens of columns all working perfectly!
You've saved me hours of work, very much appreciated.
Thanks again!