find @ and put { before start of email in A COLUMN need vb

shrinivasmj

Board Regular
Joined
Aug 29, 2012
Messages
140
all data is in excel in A column need a vb were it search for @ in each cell and put { diameter before the email id

vb or macro

in a cell data is

"August 5,2004" 06:16:00 PM tonytruex klblessed@hotmail com Chris Green rt 2 box 67 Fort Polk ga 94137 (310)639-4841 ("408,1263-3208 Anytime Refinance First With Debt and CashOut 270438 Multy Family Home 207490 2003 333694 7.104 Adjustable 9 _Excelent BAE SYSTEMS 7 8497 Visa Gold Credit card 5813638338123290

replace to

"August 5,2004" 06:16:00 PM tonytruex { klblessed@hotmail com Chris Green rt 2 box 67 Fort Polk ga 94137 (310)639-4841 ("408,1263-3208 Anytime Refinance First With Debt and CashOut 270438 Multy Family Home 207490 2003 333694 7.104 Adjustable 9 _Excelent BAE SYSTEMS 7 8497 Visa Gold Credit card 5813638338123290

u can it as to put { before e mail id { klblessed@hotmail com
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Couldn't you simply use Find / Replace to do this ??
 
Upvote 0
Give this macro a try...
Code:
[table="width: 500"]
[tr]
	[td]Sub AddOpeningBraceBeforeEmailAddress()
  Dim Cell As Range
  On Error GoTo NoData
  For Each Cell In Cells.SpecialCells(xlConstants)
    If InStr(Cell.Value, "@") Then
      Cell.Value = Trim(Application.Replace(Cell.Value, InStrRev(" " & Cell.Value, " ", InStr(Cell.Value, "@")), 0, "{ "))
    End If
  Next
NoData:
End Sub[/td]
[/tr]
[/table]
 
Upvote 0
hi
thanks it working , one more i need after @ to put at end {
Here it is...

Code:
[table="width: 500"]
[tr]
	[td]Sub AddClosingBraceAfterEmailAddress()
  Dim Cell As Range
  On Error GoTo NoData
  For Each Cell In Cells.SpecialCells(xlConstants)
    If InStr(Cell.Value, "@") Then
      Cell.Value = Trim(Application.Replace(Cell.Value, InStr(InStr(Cell.Value, "@"), Cell.Value & " ", " "), 0, " }"))
    End If
  Next
NoData:
End Sub[/td]
[/tr]
[/table]

Did you want a single macro to do both at the same time? If so...

Code:
[table="width: 500"]
[tr]
	[td]Sub AddOpeningAndClosingBraceAroundEmailAddresses()
  Dim Cell As Range
  On Error GoTo NoData
  For Each Cell In Cells.SpecialCells(xlConstants)
    If InStr(Cell.Value, "@") Then
      Cell.Value = Trim(Application.Replace(Cell.Value, InStrRev(" " & Cell.Value, " ", InStr(Cell.Value, "@")), 0, "{ "))
      Cell.Value = Trim(Application.Replace(Cell.Value, InStr(InStr(Cell.Value, "@"), Cell.Value & " ", " "), 0, " }"))
    End If
  Next
NoData:
End Sub[/td]
[/tr]
[/table]
 
Upvote 0

Forum statistics

Threads
1,223,249
Messages
6,171,031
Members
452,374
Latest member
keccles

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