Importing Excel Sheet Problem

M

Mo

Hi,

I am trying to import an excel sheet into an excel file. It works,
however, cells that are more than 255 chars are cutting off...here is
the code I am using...Please help!!!

'*********************IMPORT EXCEL FILE*********************
Dim Count As Integer
Dim Response As Variant

'***************New Code TO Extract**********************
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim CurrentWB As Excel.Workbook
Dim FileName As Variant


FileName = Application.GetOpenFilename _
(filefilter:="Excel Workbook(*.xls),*.txt,All
Files(*.*),*.*")
If FileName = False Then
MsgBox "You did not select a file."
Sheets("Setup").Select
Exit Sub
End If


Application.ScreenUpdating = False
Sheets("RawData").Select
Cells.Select
Selection.ClearContents
Set CurrentWB = ThisWorkbook
Set xlBook = Workbooks.Open(FileName, False, True)
Set xlSheet = xlBook.Worksheets(1)
xlSheet.Copy after:=CurrentWB.Sheets(CurrentWB.Sheets.Count)
xlBook.Close savechanges:=False
'Application.ScreenUpdating = True
CurrentWB.Sheets(CurrentWB.Sheets.Count).Select
Cells.Select
Application.CutCopyMode = False
Selection.Copy
Sheets("RawData").Select
Cells.Select
ActiveSheet.Paste
Columns("A:Z").EntireColumn.AutoFit
Application.DisplayAlerts = False
Worksheets(CurrentWB.Sheets.Count).Delete
Application.DisplayAlerts = True

Set xlSheet = Nothing
Set xlBook = Nothing
Set CurrentWB = Nothing
'*********************IMPORT EXCEL FILE*********************
 
J

Jim Rech

This might be on point:

http://support.microsoft.com/kb/213548/en-us


--
Jim
| Hi,
|
| I am trying to import an excel sheet into an excel file. It works,
| however, cells that are more than 255 chars are cutting off...here is
| the code I am using...Please help!!!
|
| '*********************IMPORT EXCEL FILE*********************
| Dim Count As Integer
| Dim Response As Variant
|
| '***************New Code TO Extract**********************
| Dim xlBook As Excel.Workbook
| Dim xlSheet As Excel.Worksheet
| Dim CurrentWB As Excel.Workbook
| Dim FileName As Variant
|
|
| FileName = Application.GetOpenFilename _
| (filefilter:="Excel Workbook(*.xls),*.txt,All
| Files(*.*),*.*")
| If FileName = False Then
| MsgBox "You did not select a file."
| Sheets("Setup").Select
| Exit Sub
| End If
|
|
| Application.ScreenUpdating = False
| Sheets("RawData").Select
| Cells.Select
| Selection.ClearContents
| Set CurrentWB = ThisWorkbook
| Set xlBook = Workbooks.Open(FileName, False, True)
| Set xlSheet = xlBook.Worksheets(1)
| xlSheet.Copy after:=CurrentWB.Sheets(CurrentWB.Sheets.Count)
| xlBook.Close savechanges:=False
| 'Application.ScreenUpdating = True
| CurrentWB.Sheets(CurrentWB.Sheets.Count).Select
| Cells.Select
| Application.CutCopyMode = False
| Selection.Copy
| Sheets("RawData").Select
| Cells.Select
| ActiveSheet.Paste
| Columns("A:Z").EntireColumn.AutoFit
| Application.DisplayAlerts = False
| Worksheets(CurrentWB.Sheets.Count).Delete
| Application.DisplayAlerts = True
|
| Set xlSheet = Nothing
| Set xlBook = Nothing
| Set CurrentWB = Nothing
| '*********************IMPORT EXCEL FILE*********************
|
 

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