HOW i can split data !

AhmedRady

New Member
Joined
May 22, 2019
Messages
20
Hello All,
i need to split the some data like :
Ahmed // ABC.com // call // 123456789
or
Ahmed // Abc.com // Mail // abc.com issue

and i need when ever the excel find that format *.com/*.net/*.edu put that data in product column and wherever find number put it in the number column
o know i should use split but i don't know how ????

to be
like that format :
nameproductcontact waynumbersubjectissue
AHMEDABC.COMcall123456789
ahmedabc.commailabc.com issue

<tbody>
</tbody>
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
i used that method but still not match all i need :oops::oops::oops:

Sub splittext()

Dim textstring As String, warray() As String, counter As Integer, strg As String


textstring = Range("A3").Value
warray() = split(textstring, "//")
For counter = LBound(warray) To UBound(warray)


strg = warray(counter)
Cells(counter + 3, 1).Value = Trim(strg)
Next counter


End Sub
 
Upvote 0
Using Power Query which is part of Excel and available in Versions 2010 and later here is the Mcode
Code:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Split Column by Delimiter" = Table.SplitColumn(Source, "Column1", Splitter.SplitTextByDelimiter("//", QuoteStyle.Csv), {"Column1.1", "Column1.2", "Column1.3", "Column1.4"}),
    #"Added Custom" = Table.AddColumn(#"Split Column by Delimiter", "Custom", each if Value.Is(Value.FromText([Column1.4]), type text) then [Column1.4] else ""),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each if Value.Is(Value.FromText([Column1.4]), type number) then [Column1.4] else ""),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Column1.4"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Column1.1", "Name"}, {"Column1.2", "Product"}, {"Column1.3", "Contact Way"}, {"Custom", "Number"}, {"Custom.1", "Subject"}})
in
    #"Renamed Columns"

vABCDE
1NameProductContact WayNumberSubject
2Ahmed ABC.com call 123456789
3Ahmed Abc.com Mail abc.com issue
 
Upvote 0
VBA solution:
Rich (BB code):
Sub SplitText1()
 
  Const SourceRange = "A2:A3" ' <-- Source data range, change to suit
  Const DestCell = "C3"       ' <-- First destination cell, change to suit
 
  Dim a As Variant, Cell As Range, i As Long
 
  For Each Cell In Range(SourceRange)
    a = Split(Cell.Value, " // ")
    ReDim Preserve a(0 To 4)
    If Val(a(3)) = a(3) Then
      a(4) = a(3)
      a(3) = Empty
    End If
    Range(DestCell).Offset(i).Resize(, 5).Value = a
    i = i + 1
  Next
 
End Sub
 
Last edited:
Upvote 0
According to the destination data layout in post 1 this: If Val(a(3)) = a(3) Then
should be relpaced by that: If Val(a(3)) <> a(3) Then
 
Upvote 0
Thanks very much for your great effort but i can't add power query, the issue is related to my operating system i can't update "explorer 8" which is should be " explorer 9" at lest to be enable run the power query on my MOS, i hope if there is another solution.
 
Upvote 0
it's working , thanks , but i need to be at that level which enable me to implement my ideas
VBA solution:
Rich (BB code):

Sub SplitText1()
 
  Const SourceRange = "A2:A3" ' <-- Source data range, change to suit
  Const DestCell = "C3"       ' <-- First destination cell, change to suit
 
  Dim a As Variant, Cell As Range, i As Long
 
  For Each Cell In Range(SourceRange)
    a = Split(Cell.Value, " // ")
    ReDim Preserve a(0 To 4)
    If Val(a(3)) = a(3) Then
      a(4) = a(3)
      a(3) = Empty
    End If
    Range(DestCell).Offset(i).Resize(, 5).Value = a
    i = i + 1
  Next
 
End Sub
 
Upvote 0
Have you even looked at the power query solution I provided you? Very simple and easy to enable.

If you don't know about PQ then look at this: https://www.poweredsolutions.co/2015/01/23/power-query/
yes i try but the issue is related to add it to my MOS ,as i mentioned before i used old version of Explorer " explorer 8" , the below error message appears "Microsoft power query for excel x64 setup wizard ended prematurely " and informed my " please make sure that you have internet explorer 9 RTM or later installed"
 
Upvote 0

Forum statistics

Threads
1,215,564
Messages
6,125,579
Members
449,237
Latest member
Chase S

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