Beginner Question

N

nadhra

Hi,

Can anyone please help me to edit this code :

Selection.TextToColumns Destination:=Range("B31"),
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False,
Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True,
OtherChar _
:="-", FieldInfo:=Array(Array(1, 1), Array(2, 1)),
TrailingMinusNumbers:=True
End Sub

so that I can run the macros for every cell selected?

and later, do every cell and then run the macros on other sheet in the
worksheet?

Thank you very much!

Nadhra
 
D

Dave Peterson

It's difficult to know what you're doing since you used the current selection
and B31.

I assumed that you want to parse the data in the first column of a single area
range and put it in the adjacent 3 columns.

If that's true:

Option Explicit
Sub testme()

Dim myRng As Range

'one area at a time, one column in that area
Set myRng = Selection.Areas(1).Columns(1)

Application.DisplayAlerts = False
With myRng
On Error Resume Next
.Cells.TextToColumns Destination:=.Cells.Offset(0, 1), _
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, _
Tab:=True, _
Semicolon:=False, _
Comma:=False, _
Space:=False, _
Other:=True, _
OtherChar:="-", _
FieldInfo:=Array(Array(1, 1), Array(2, 1)), _
TrailingMinusNumbers:=True
If Err.Number <> 0 Then
MsgBox "Something bad happened with: " & myRng.Address(0, 0)
Err.Clear
End If
On Error GoTo 0
End With

Application.DisplayAlerts = True

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top