Hi,
quite often I get spreadsheets containing product numbers - however, they often have a "#" as delimiter followed by a three letter option code. The data can come in a any column and vary from 5 to 1000 rows. So, I wan to make a permanent tool where I can select the column with the specific data - push the macro button (in my own tool view in the ribbon) and remove (delete) everything after the delimiter.
I have recorded a macro. However, the selection is static. I have also tried using various selection methods, but it always strands at the beginning of the texttocolumns code.
The error message I get is: Compile Error: Expected Function or Variable (highlighting "Selection" in the code). As if it doesn't have a selection to work with(?).
Also: not sure if the data in "Field Info" is correct. I guess this also should be dynamic.
I appreciate all the help I can get.
quite often I get spreadsheets containing product numbers - however, they often have a "#" as delimiter followed by a three letter option code. The data can come in a any column and vary from 5 to 1000 rows. So, I wan to make a permanent tool where I can select the column with the specific data - push the macro button (in my own tool view in the ribbon) and remove (delete) everything after the delimiter.
I have recorded a macro. However, the selection is static. I have also tried using various selection methods, but it always strands at the beginning of the texttocolumns code.
The error message I get is: Compile Error: Expected Function or Variable (highlighting "Selection" in the code). As if it doesn't have a selection to work with(?).
Also: not sure if the data in "Field Info" is correct. I guess this also should be dynamic.
I appreciate all the help I can get.
Code:
Sub remove_option_code()'
Dim rng As Range
Set rng = ActiveSheet.Range.CurrentRegion
'
'
rng.Select
Selection.TextToColumns _
Destination:=rng, _
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, _
Comma:=False, _
Space:=False, _
Other:=True, _
OtherChar:="#", _
FieldInfo:=Array(Array(1, 1), Array(2, 9)), _
TrailingMinusNumbers:=True
End Sub