Error 1004 in VBA

NEAnthony

New Member
Joined
Nov 24, 2008
Messages
13
Hi

I have following VBA error message 1004 run time error and at debug I have following area highlighted

Columns("E:E").Select
Selection.TextToColumns Destination:=Range("E1"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 4), Array(19, 1)), TrailingMinusNumbers:=True

Is this a problem with the .Select?

Thanks in advance
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
No that error means that no data was selected. Are you sure the sheet with the data on is active at that stage of the subroutine?

If not you will have to change your code to activate the correct sheet. Or just skip the selection so it reads

Columns("E:E").TextToColumns Destination:=Range("E1"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 4), Array(19, 1)), TrailingMinusNumbers:=True
 
Upvote 0
Hi

I stil have the same problem.

I have the following rutine

Private Sub CommandButton2_Click()
Sheets("Data paneler").Columns("G:G").Copy
Sheets("Sheet4").Range("E1").PasteSpecial xlValues
Sheets("Data paneler").Range("B:D,I:I").Copy
Sheets("Sheet4").Range("A1").PasteSpecial xlValues
Columns("E:E").TextToColumns Destination:=Range("E1"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 4), Array(19, 1)), TrailingMinusNumbers:=True
Range("F1").Select
End Sub

After Sheets("Sheet4").Range("A1").PasteSpecial xlValues excel do run a cell update that takes around 15 seconds before it continues with with the rest of the program which it failes on. Are the 15 seconds the problem?
 
Upvote 0
Code:
Private Sub CommandButton2_Click()
Sheets("Data paneler").Columns("G:G").Copy
Sheets("Sheet4").Range("E1").PasteSpecial xlValues
Sheets("Data paneler").Range("B:D,I:I").Copy
Sheets("Sheet4").Range("A1").PasteSpecial xlValues
[B]Sheets("Sheet4").[/B]Columns("E:E").TextToColumns Destination:=Range("E1"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 4), Array(19, 1)), TrailingMinusNumbers:=True
[B]Sheets("Sheet4").[/B]Range("F1").Select
End Sub

That should sort it.
 
Upvote 0
It sort of works. If I leave out Sheets("Sheet4").Range("F1").Select it works perfect.

I guess I have a problem with the .Select command. How come?
 
Upvote 0
Rich (BB code):
Private Sub CommandButton2_Click()
Sheets("Data paneler").Columns("G:G").Copy
Sheets("Sheet4").Range("E1").PasteSpecial xlValues
Sheets("Data paneler").Range("B:D,I:I").Copy
Sheets("Sheet4").Range("A1").PasteSpecial xlValues
Sheets("Sheet4").Columns("E:E").TextToColumns Destination:=Range("E1"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 4), Array(19, 1)), TrailingMinusNumbers:=True
Sheets("Sheet4").Select
Sheets("Sheet4").Range("F1").Select
End Sub

I forgot you have to select the sheet first. Silly me.
 
Upvote 0

Forum statistics

Threads
1,206,754
Messages
6,074,750
Members
446,082
Latest member
fgiron83

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