extract Numbers into strings

Maurizio

Well-known Member
Joined
Oct 15, 2002
Messages
687
Office Version
  1. 2007
Platform
  1. Windows
Hi all,

with a string so:

27.990,000 0,00 0,00
MILANO 27.990,000 34,72 850,00
...

with vba how can I get this into 4 cells:

(empty)|27.990,000|0,00|0,00
MILANO | 27.990,000 | 34,72 | 850,00


Tia.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Assuming the original strings are in column A staring at row 2, try this.

VBA Code:
Sub FourColumns()
  With Range("B2:B" & Range("A" & Rows.Count).End(xlUp).Row)
    .Formula = "=IF(ISNUMBER(LEFT(A2,1)+0),"" "","""") & A2"
    .Value = .Value
    .TextToColumns DataType:=xlDelimited, Space:=True, Other:=False
  End With
End Sub
 
Upvote 0
Assuming the original strings are in column A staring at row 2, try this.

VBA Code:
Sub FourColumns()
  With Range("B2:B" & Range("A" & Rows.Count).End(xlUp).Row)
    .Formula = "=IF(ISNUMBER(LEFT(A2,1)+0),"" "","""") & A2"
    .Value = .Value
    .TextToColumns DataType:=xlDelimited, Space:=True, Other:=False
  End With
End Sub

Many tnks
 
Upvote 0
....and with:

38 CROI-LOGIS
B/152 RIOV LOGI SRL
B/56 SCARRONI

IN 2 COLUMNS ?

38 | CROI-LOGIS
B/152 | RIOV LOGI SRL
B/56 | SCARRONI

Tia.
 
Upvote 0
Many tnks
You're welcome.


...and with:

38 CROI-LOGIS
B/152 RIOV LOGI SRL
B/56 SCARRONI

IN 2 COLUMNS ?
Does this do what you want?

VBA Code:
Sub TwoColumns()
  With Range("B2:B" & Range("A" & Rows.Count).End(xlUp).Row)
    .Value = Evaluate("substitute(" & .Offset(, -1).Address & ","" "","";"",1)")
    .TextToColumns DataType:=xlDelimited, Semicolon:=True, Space:=False, Other:=False
  End With
End Sub


BTW, suggest that you update your Account details to show us version information as it may affect the most appropriate suggestion.
1582063280902.png


.. and also give us sample data in a better format? .. XL2BB
 
Upvote 0
Sub TwoColumns() With Range("B2:B" & Range("A" & Rows.Count).End(xlUp).Row) .Value = Evaluate("substitute(" & .Offset(, -1).Address & ","" "","";"",1)") .TextToColumns DataType:=xlDelimited, Semicolon:=True, Space:=False, Other:=False End With
... sorry I get:


38​
CROI-LOGIS
38​
CROI-LOGIS
38​
CROI-LOGIS
and not
38​
CROI-LOGIS
B/152 RIOV LOGI SRL
B/56 SCARRONI
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,717
Members
448,985
Latest member
chocbudda

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