VBA Button to clear column of text and leave just numbers

daltendavis

New Member
Joined
Jun 26, 2018
Messages
37
I am pasting into column A row 1 and need a macro I can apply to a button that takes out all text from what has been pasted and leaves every row with the same digits just without text.

Often times there will be up to 75 rows pasted in column A.

I need a macro that I can apply to a button to just pull the text out of the numbers leaving them in the same location on the sheet so I can then click another button which I have set up to value the numbers in the column.

Thank you
 
This is what I want it to do but can it export the results to sheet 2 of the workbook rather than just replacing where I pasted the data. Thank you very much
Sure, we just need to add the sheet reference to the last two lines of code...
Code:
[table="width: 500"]
[tr]
	[td]Sub NumbersAndFractionalAmounts()
  Dim R As Long, X As Long, Fract As Double
  Dim Combo As String, Txt As String, Vals() As String
  For R = 1 To Cells(Rows.Count, "A").End(xlUp).Row
    Txt = Cells(R, "A").Value
    For X = 1 To Len(Txt)
      If Mid(Txt, X, 1) Like "[!0-9 ]" Then Mid(Txt, X) = " "
    Next
    Txt = Application.Trim(Txt)
    If Len(Txt) Then
      Fract = Format(1 / (Len(Txt) - Len(Replace(Txt, " ", "")) + 1), ".##")
      Txt = Replace(Txt, " ", "|" & Fract & " ") & "|" & Fract
    End If
    Combo = Combo & " " & Txt
  Next
  Vals = Split(Application.Trim(Combo))
  [B][COLOR="#FF0000"]Sheets("Sheet2").[/COLOR][/B]Range("A1").Resize(UBound(Vals) + 1) = Application.Transpose(Vals)
  [B][COLOR="#FF0000"]Sheets("Sheet2").[/COLOR][/B]Columns("A").TextToColumns , xlDelimited, , , False, False, False, False, True, "|", Array(Array(1, 2), Array(2, 1))
End Sub[/td]
[/tr]
[/table]
 
Upvote 0

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Forum statistics

Threads
1,216,126
Messages
6,129,004
Members
449,480
Latest member
yesitisasport

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