Adding Suffix to a cell based on value of a another Cell

aaronr

New Member
Joined
Jul 8, 2010
Messages
34
i'm dealing with columns A and F. I need to add letter A to end all values in Columns A if Column F has Level or Roof in columns F.

Data before modified
Column A Column F
P1.00LEVEL
P1.09LEVEL
P1.10LEVEL
M1.11ROOF PLAN
M1.12ROOF PLAN LOW
P2.00
P4.00
P5.00
P6.00
Data after modified

<colgroup><col><col></colgroup><tbody>
</tbody>
Column A Column F
P1.00ALEVEL
P1.09ALEVEL
P1.10ALEVEL
M1.11AROOF PLAN
M1.12AROOF PLAN LOW
P2.00
P4.00
P5.00
P6.00

<colgroup><col><col></colgroup><tbody>
</tbody>
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
If you want them modified at the same locations, you will need a macro.
You ok with that ?
 
Upvote 0
Try
Code:
Option Compare Text
Sub MM1()
Dim lr As Long, r As Long
lr = Cells(Rows.Count, "A").End(xlUp).Row
For r = lr To 1 Step -1
    If InStr(Range("F" & r), "Level") Or InStr(Range("F" & r), "roof") Then
        Range("A" & r).Value = Range("A" & r).Value & "A"
    End If
Next r
End Sub
 
Upvote 0
Here is another macro that should also work...
Code:
[table="width: 500"]
[tr]
	[td]Sub AddSuffixA()
  Dim LastRow As Long
  LastRow = Cells(Rows.Count, "A").End(xlUp).Row
  Range("A1:A" & LastRow) = Evaluate(Replace("IF(ISNUMBER(SEARCH(""LEVEL"",F1:F#))+ISNUMBER(SEARCH(""ROOF"",F1:F#)),A1:A#&""A"",A1:A#)", "#", LastRow))
End Sub[/td]
[/tr]
[/table]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,120
Members
451,399
Latest member
alchavar

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