Need to separate email addresses, where they have no separation!

larrylime

New Member
Joined
Dec 7, 2015
Messages
11
Last edited:
This is NOT vba
This is PowerQuery (Get&Transform) (Excel 2010/2013 add-in, Excel 2016 and higher - built-in)

what is your Excel version?
 
Upvote 0

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Leith, I have 2 word docx saved here: https://drive.google.com/drive/folders/1K7BOgJD9JtweWSyDCoRCjrqgTJwp0HlX?usp=sharing


Hello larrylime,

I would say the problem is the emails are HTML and not pure text. That is why the Word document displayed them correctly. The list was most likely either an HTML Table, or Unordered List, either of which Excel can not display correctly after a Paste operation because there is no new line character at the end of the email. Seeing the Word document would have told me exactly what I needed to know and would have guided me in providing a solution.

 
Upvote 0
Logit, I tried the code in a macro and it didn't really do much, just posted much of the content in the 3rd row instead. Downloaded the workbook (thanks for that!) but when I opened it, excel came up and a message said "There was a problem sending the command to the program" I am running windows 7 and excel 2007
 
Upvote 0
.
I tested this revised version with data you provided for download. It works.

Code:
Sub replaceStringInCell()


    'Source: https://powerspreadsheets.com/
    'For further information: https://powerspreadsheets.com/excel-vba-replace-substitute/


    'declare object variable to hold reference to cell you work with
    Dim myCell As Range


    'declare variables to hold parameters for string replacement (string to replace, replacement string, and number of replacements)
    Dim myStringToReplace As String
    Dim myReplacementString As String
    Dim myNumberOfReplacements As Long


    'identify cell you work with
    Set myCell = ActiveSheet.Range("A1")


    'specify parameters for string replacement (string to replace, replacement string, and number of replacements)
    myStringToReplace = "com"
    myReplacementString = "com/"
    myNumberOfReplacements = 300


    'replace string in cell you work with, and assign resulting string to Range.Value property of cell you work with
    myCell.Value = Replace(Expression:=myCell.Value, Find:=myStringToReplace, Replace:=myReplacementString, Count:=myNumberOfReplacements)
Macro1
End Sub


Sub Macro1()
'
' Macro1 Macro
'


'
    Range("A1").Select
    Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
        TextQualifier:=xlNone, ConsecutiveDelimiter:=False, Tab:=False, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
        :="/", FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1)), _
        TrailingMinusNumbers:=True
ConvertRangeToColumn
End Sub




Sub ConvertRangeToColumn()
'Updateby20131126
Dim Range1 As Range, Range2 As Range, Rng As Range
Dim rowIndex As Integer
'xTitleId = "KutoolsforExcel"
Set Range1 = ActiveSheet.Range("A1:XFD1")
Set Range2 = ActiveSheet.Range("A3")
rowIndex = 0
Application.ScreenUpdating = False
For Each Rng In Range1.Rows
    Rng.Copy
    Range2.Offset(rowIndex, 0).PasteSpecial Paste:=xlPasteAll, Transpose:=True
    rowIndex = rowIndex + Rng.Columns.Count
Next
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Hey Logit! Getting closer! It kind of worked. So the list in cell 1 is 27,000 emails addresses. Your macros only ran to cell 303, then the rest of the list stayed in that cell. Other problems: .edu and .net, did not separate, and steve@comcast.net was split into steve@com cast.netsammy etc.




.
I tested this revised version with data you provided for download. It works.

Code:
Sub replaceStringInCell()


    'Source: https://powerspreadsheets.com/
    'For further information: https://powerspreadsheets.com/excel-vba-replace-substitute/


    'declare object variable to hold reference to cell you work with
    Dim myCell As Range


    'declare variables to hold parameters for string replacement (string to replace, replacement string, and number of replacements)
    Dim myStringToReplace As String
    Dim myReplacementString As String
    Dim myNumberOfReplacements As Long


    'identify cell you work with
    Set myCell = ActiveSheet.Range("A1")


    'specify parameters for string replacement (string to replace, replacement string, and number of replacements)
    myStringToReplace = "com"
    myReplacementString = "com/"
    myNumberOfReplacements = 300


    'replace string in cell you work with, and assign resulting string to Range.Value property of cell you work with
    myCell.Value = Replace(Expression:=myCell.Value, Find:=myStringToReplace, Replace:=myReplacementString, Count:=myNumberOfReplacements)
Macro1
End Sub


Sub Macro1()
'
' Macro1 Macro
'


'
    Range("A1").Select
    Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
        TextQualifier:=xlNone, ConsecutiveDelimiter:=False, Tab:=False, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
        :="/", FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1)), _
        TrailingMinusNumbers:=True
ConvertRangeToColumn
End Sub




Sub ConvertRangeToColumn()
'Updateby20131126
Dim Range1 As Range, Range2 As Range, Rng As Range
Dim rowIndex As Integer
'xTitleId = "KutoolsforExcel"
Set Range1 = ActiveSheet.Range("A1:XFD1")
Set Range2 = ActiveSheet.Range("A3")
rowIndex = 0
Application.ScreenUpdating = False
For Each Rng In Range1.Rows
    Rng.Copy
    Range2.Offset(rowIndex, 0).PasteSpecial Paste:=xlPasteAll, Transpose:=True
    rowIndex = rowIndex + Rng.Columns.Count
Next
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Hey Logit, I was able to get close enough with your code and am pretty sure I can solve the rest. Thanks so much for your assistance!!!!
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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