scottiedawg4
New Member
- Joined
- Jul 25, 2011
- Messages
- 49
I am trying to import a range from a CSV file into an Excel worksheet.
Code:
'Prompt user for location of alltxt data file
openAlltxt = Application.GetOpenFilename(Title:="Locate alltxt File", MultiSelect:=False)
If openAlltxt = "False" Then
Exit Sub 'exit if they press Cancel
Else
Dim WB As Workbook
Dim Alltxt As Workbook
Set WB = ActiveWorkbook
Set Alltxt = Application.Workbooks.Open(openAlltxt)
Alltxt.ActiveSheet.Range("A1:F200000").Copy
ActiveWorkbook.ActiveWorksheet.Range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.NumberFormat = "General"
On Error Resume Next
Alltxt.Close False
End If
*End Code
I get the runtime error for the "ActiveWorkbook.ActiveWorksheet" line
Any thoughts?
Thanks
Code:
'Prompt user for location of alltxt data file
openAlltxt = Application.GetOpenFilename(Title:="Locate alltxt File", MultiSelect:=False)
If openAlltxt = "False" Then
Exit Sub 'exit if they press Cancel
Else
Dim WB As Workbook
Dim Alltxt As Workbook
Set WB = ActiveWorkbook
Set Alltxt = Application.Workbooks.Open(openAlltxt)
Alltxt.ActiveSheet.Range("A1:F200000").Copy
ActiveWorkbook.ActiveWorksheet.Range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.NumberFormat = "General"
On Error Resume Next
Alltxt.Close False
End If
*End Code
I get the runtime error for the "ActiveWorkbook.ActiveWorksheet" line
Any thoughts?
Thanks