Macro Help

john62290

New Member
Joined
Dec 15, 2021
Messages
26
Office Version
  1. 365
Platform
  1. Windows
Hey, I am trying to create a macro that will remove numbers in one column from different sheets but leave the text that is in there. It will be six different sheets and the total numbers in the columns fluctuate throughout the day. I need a way for it to clear the data without clearing the text. I have gotten something but it clears the text as well. Thank you for your help!
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
VBA Code:
Sub RemoveNumbersFromColumnB()
  Dim X As Long, R As Long, Data As Variant
  Data = Range("B1", Cells(Rows.Count, "B").End(xlUp))
  For R = 1 To UBound(Data)
    For X = 1 To Len(Data(R, 1))
      If Mid(Data(R, 1), X, 1) Like "[0-9]" Then Mid(Data(R, 1), X) = Chr(1)
    Next
    Data(R, 1) = Application.Trim(Replace(Data(R, 1), Chr(1), ""))
  Next
  Range("B1").Resize(UBound(Data)) = Data
End Sub

VBA - Remove numbers from column
 
Upvote 0
VBA Code:
Sub RemoveNumbersFromColumnB()
  Dim X As Long, R As Long, Data As Variant
  Data = Range("B1", Cells(Rows.Count, "B").End(xlUp))
  For R = 1 To UBound(Data)
    For X = 1 To Len(Data(R, 1))
      If Mid(Data(R, 1), X, 1) Like "[0-9]" Then Mid(Data(R, 1), X) = Chr(1)
    Next
    Data(R, 1) = Application.Trim(Replace(Data(R, 1), Chr(1), ""))
  Next
  Range("B1").Resize(UBound(Data)) = Data
End Sub

VBA - Remove numbers from column
Hey, thanks for the quick response. This works but it does remove the text as well for me. 95-98% of the data is numbers so that is the format of column I. Would the data need to be in general or text format to not remove it?
 
Upvote 0

Forum statistics

Threads
1,214,951
Messages
6,122,449
Members
449,083
Latest member
Ava19

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