Add specific text to existing value for multiple column

Perzo

New Member
Joined
Apr 20, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hello
I am a total newbie to VBA and macro. I want to add some specific text to existing strings (before and after), depending on column.


original table
test.xlsx
CDEFG
23NamePartnerPr_Title_ENThemeWeb_en
24Name1P1Project1Th1https://www.ggg.fr/TechnZzz/Name1_Project1.html
25Name2P2Project2Th2https://www.ggg.fr/TechnZzz/Name2_Project2.html
Tabelle2


what I need
test.xlsx
BCDEF
28NamePartnerPr_Title_ENThemeWeb_en
29{ "type": "Feature", "properties": { "q2wHide_NAME": "Name1", "Partner": "<strong>P1</strong>","Project":"Project1","Theme": "Th1", "Web_en": "<a href=https:\/\/wwwggg.fr\/TechnZzz\/Name1_Project1.html target='_blank' rel='noreferrer noopener'style='color: #ffffff'>Information<\/a>"
30{ "type": "Feature", "properties": { "q2wHide_NAME": "Name2", "Partner": "<strong>P2</strong>","Project":"Project2","Theme": "Th2", "Web_en": "<a href=https:\/\/wwwggg.fr\/TechnZzz\/Name2_Project2.html target='_blank' rel='noreferrer noopener'style='color: #ffffff'>Information<\/a>"
Tabelle2


Thanks for the help!
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Welcome to MrExcel Message Board.
If your Data Start from Cell C24 (as Uploaded File) Try this:
VBA Code:
Sub ConvertTexts()
Dim i As Long, Lr As Long, K As String
Lr = Range("C" & Rows.Count).End(xlUp).Row
For i = 24 To Lr
Range("C" & i).Value = "{ ""type"": ""Feature"", ""properties"": { ""q2wHide_NAME"": """ & Range("C" & i).Value & """" & ","
Range("D" & i).Value = " ""Partner"": ""<strong>" & Range("D" & i).Value & "</strong>""" & ","
Range("E" & i).Value = """Project"":""" & Range("E" & i).Value & """" & ","
Range("F" & i).Value = """Theme"":""" & Range("F" & i).Value & """" & ","
K = Replace(Range("G" & i).Value, "/", "\/")
Range("G" & i).Value = " ""Web_en"": ""<a href=" & K & " " & "target='_blank' rel='noreferrer noopener'style='color: #ffffff'>Information<\/a>"""
Range("G" & i).Font.Color = 0
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,998
Messages
6,122,643
Members
449,093
Latest member
Ahmad123098

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