Xiq
Active Member
Hi great minds on the Chandoo!
I made a macro (copy pasting some things together) that removes a series of characters/text-strings/numbers, but I'm very very green in the arts of VBA and it seems to be kinda inefficient. I would greatly appreciate some (easy to understand) feedback or solution to my problem.
Please reference to my code below for the characters/text-strings/numbers I want to remove.
Many thanks!
Xiq
I made a macro (copy pasting some things together) that removes a series of characters/text-strings/numbers, but I'm very very green in the arts of VBA and it seems to be kinda inefficient. I would greatly appreciate some (easy to understand) feedback or solution to my problem.
Please reference to my code below for the characters/text-strings/numbers I want to remove.
Many thanks!
Xiq
PHP:
Sub RemoveStuff()
' Applies a "Remove" function on the selected cell or cells
' CTRL + SHIFT + D
Dim ActSheet As Worksheet
Dim SelRange As Range, cell As Range
Set ActSheet = ActiveSheet
Set SelRange = Selection
ActSheet.Select
SelRange.Select
For Each cell In SelRange
' Number Series "00-13"
cell = WorksheetFunction.Substitute(cell, "00", "")
cell = WorksheetFunction.Substitute(cell, "01", "")
cell = WorksheetFunction.Substitute(cell, "02", "")
cell = WorksheetFunction.Substitute(cell, "03", "")
cell = WorksheetFunction.Substitute(cell, "04", "")
cell = WorksheetFunction.Substitute(cell, "05", "")
cell = WorksheetFunction.Substitute(cell, "06", "")
cell = WorksheetFunction.Substitute(cell, "07", "")
cell = WorksheetFunction.Substitute(cell, "08", "")
cell = WorksheetFunction.Substitute(cell, "09", "")
cell = WorksheetFunction.Substitute(cell, "10", "")
cell = WorksheetFunction.Substitute(cell, "11", "")
cell = WorksheetFunction.Substitute(cell, "12", "")
cell = WorksheetFunction.Substitute(cell, "13", "")
' Number Series "2000-2013"
cell = WorksheetFunction.Substitute(cell, "2000", "")
cell = WorksheetFunction.Substitute(cell, "2001", "")
cell = WorksheetFunction.Substitute(cell, "2002", "")
cell = WorksheetFunction.Substitute(cell, "2003", "")
cell = WorksheetFunction.Substitute(cell, "2004", "")
cell = WorksheetFunction.Substitute(cell, "2005", "")
cell = WorksheetFunction.Substitute(cell, "2006", "")
cell = WorksheetFunction.Substitute(cell, "2007", "")
cell = WorksheetFunction.Substitute(cell, "2008", "")
cell = WorksheetFunction.Substitute(cell, "2009", "")
cell = WorksheetFunction.Substitute(cell, "2010", "")
cell = WorksheetFunction.Substitute(cell, "2011", "")
cell = WorksheetFunction.Substitute(cell, "2012", "")
cell = WorksheetFunction.Substitute(cell, "2013", "")
' Letter (lowerCase only) Series "a-z"
cell = WorksheetFunction.Substitute(cell, "a", "")
cell = WorksheetFunction.Substitute(cell, "b", "")
cell = WorksheetFunction.Substitute(cell, "c", "")
cell = WorksheetFunction.Substitute(cell, "d", "")
cell = WorksheetFunction.Substitute(cell, "e", "")
cell = WorksheetFunction.Substitute(cell, "f", "")
cell = WorksheetFunction.Substitute(cell, "g", "")
cell = WorksheetFunction.Substitute(cell, "h", "")
cell = WorksheetFunction.Substitute(cell, "i", "")
cell = WorksheetFunction.Substitute(cell, "j", "")
cell = WorksheetFunction.Substitute(cell, "k", "")
cell = WorksheetFunction.Substitute(cell, "l", "")
cell = WorksheetFunction.Substitute(cell, "m", "")
cell = WorksheetFunction.Substitute(cell, "n", "")
cell = WorksheetFunction.Substitute(cell, "o", "")
cell = WorksheetFunction.Substitute(cell, "p", "")
cell = WorksheetFunction.Substitute(cell, "q", "")
cell = WorksheetFunction.Substitute(cell, "r", "")
cell = WorksheetFunction.Substitute(cell, "s", "")
cell = WorksheetFunction.Substitute(cell, "t", "")
cell = WorksheetFunction.Substitute(cell, "u", "")
cell = WorksheetFunction.Substitute(cell, "v", "")
cell = WorksheetFunction.Substitute(cell, "w", "")
cell = WorksheetFunction.Substitute(cell, "x", "")
cell = WorksheetFunction.Substitute(cell, "y", "")
cell = WorksheetFunction.Substitute(cell, "z", "")
' Character Series char(0032), char(0160) and "-/[]&(),'`."
cell = WorksheetFunction.Substitute(cell, "-", "")
cell = WorksheetFunction.Substitute(cell, "/", "")
cell = WorksheetFunction.Substitute(cell, "[", "")
cell = WorksheetFunction.Substitute(cell, "]", "")
cell = WorksheetFunction.Substitute(cell, "&", "")
cell = WorksheetFunction.Substitute(cell, "(", "")
cell = WorksheetFunction.Substitute(cell, ")", "")
cell = WorksheetFunction.Substitute(cell, ",", "")
cell = WorksheetFunction.Substitute(cell, "'", "")
cell = WorksheetFunction.Substitute(cell, "`", "")
cell = WorksheetFunction.Substitute(cell, ".", "")
cell = WorksheetFunction.Substitute(cell, " ", "")
cell = WorksheetFunction.Substitute(cell, " ", "")
Next
End Sub