September 26, 2018
Hi,
Could you please help me to create macro to add Public words at the end of names as below.
Public words: Corp Inc. Company CO Corporation co,ltd
Name: Apple
Macro result:
Apple Corp
Apple Inc.
Apple Company
Apple Corporation
Apple co,ltd
Please check attached file to get sample.
Thanks;
Ehab
VIP
Trusted Members
June 25, 2016
Try this
Sub AddPublicWord()
Dim CoArray() As Variant
Dim PWArray() As Variant
Dim r As Long
Dim s As Long
Dim i As Long
i = 2
CoArray = Sheets("Sheet1").Range("A2:A4").Value
PWArray = Sheets("Sheet1").Range("B2:B7").Value
For r = 1 To UBound(CoArray, 1)
For s = 1 To UBound(PWArray, 1)
Cells(i, 5) = CoArray(r, 1) & " " & PWArray(s, 1)
i = i + 1
Next s
Next r
End Sub
September 26, 2018
You are amazing! Thank you so much!
I just want to repeat the name as below.
Name | Public words | New Name |
Apple | Corp | Apple Corp |
Apple | Inc. | Apple Inc. |
Apple | Company | Apple Company |
Apple | CO | Apple CO |
Apple | Corporation | Apple Corporation |
Apple | co,ltd | Apple co,ltd |
Please check attached file.
VIP
Trusted Members
June 25, 2016
Try this
Sub AddPublicWord()
Dim CoArray() As Variant
Dim PWArray() As Variant
Dim r As Long
Dim s As Long
Dim i As Long
i = 2
CoArray = Sheets("Sheet1").Range("A2:A4").Value
PWArray = Sheets("Sheet1").Range("B2:B20").Value
For r = 1 To UBound(CoArray, 1)
For s = 1 To UBound(PWArray, 1)
Cells(i, 5) = CoArray(r, 1) & " " & PWArray(s, 1)
Cells(i, 6) = CoArray(r, 1)
i = i + 1
Next s
Next r
End Sub
1 Guest(s)