A
Anita
Hi,
I've got a Macro which is collecting data from all first sheets of all
xls documents in a certain folder. But doing this, text gets lost.
eg. I've got a cell containing the discription of a product, it's 296
characters (incl. spaces).
When I import the sheet info a new document using a Macro the cell
only contains 255 characters.
I'm using the following Macro:
Sub Products_verzamelen()
Dim basebook As Workbook
Dim mybook As Workbook
Dim sourceRange As Range
Dim destrange As Range
Dim FNames As String
Dim MyPath As String
Dim SaveDriveDir As String
SaveDriveDir = CurDir
MyPath = "HobbyHandig:Internet handelingenroducts:" 'adapt it to
your folder
ChDrive MyPath
ChDir MyPath
FNames = Dir("", 0)
If Len(FNames) = 0 Then
MsgBox "No files in the Directory"
ChDrive SaveDriveDir
ChDir SaveDriveDir
Exit Sub
End If
Application.ScreenUpdating = False
Set basebook = ThisWorkbook
Do While FNames <> ""
Set mybook = Workbooks.Open(FNames)
mybook.Worksheets("Master").Copy After:= _
basebook.Sheets(basebook.Sheets.Count)
On Error Resume Next
ActiveSheet.Name = mybook.Name
On Error GoTo 0
' You can use this if you want to copy only the values
' With ActiveSheet.UsedRange
' .Value = .Value
' End With
mybook.Close False
FNames = Dir()
Loop
ChDrive SaveDriveDir
Application.ScreenUpdating = True
End Sub
Some people at this forum developed this for me, I don't really know
how Macro's work.
Can someone solve my problem?
Thanks in advance,
Anita
I've got a Macro which is collecting data from all first sheets of all
xls documents in a certain folder. But doing this, text gets lost.
eg. I've got a cell containing the discription of a product, it's 296
characters (incl. spaces).
When I import the sheet info a new document using a Macro the cell
only contains 255 characters.
I'm using the following Macro:
Sub Products_verzamelen()
Dim basebook As Workbook
Dim mybook As Workbook
Dim sourceRange As Range
Dim destrange As Range
Dim FNames As String
Dim MyPath As String
Dim SaveDriveDir As String
SaveDriveDir = CurDir
MyPath = "HobbyHandig:Internet handelingenroducts:" 'adapt it to
your folder
ChDrive MyPath
ChDir MyPath
FNames = Dir("", 0)
If Len(FNames) = 0 Then
MsgBox "No files in the Directory"
ChDrive SaveDriveDir
ChDir SaveDriveDir
Exit Sub
End If
Application.ScreenUpdating = False
Set basebook = ThisWorkbook
Do While FNames <> ""
Set mybook = Workbooks.Open(FNames)
mybook.Worksheets("Master").Copy After:= _
basebook.Sheets(basebook.Sheets.Count)
On Error Resume Next
ActiveSheet.Name = mybook.Name
On Error GoTo 0
' You can use this if you want to copy only the values
' With ActiveSheet.UsedRange
' .Value = .Value
' End With
mybook.Close False
FNames = Dir()
Loop
ChDrive SaveDriveDir
Application.ScreenUpdating = True
End Sub
Some people at this forum developed this for me, I don't really know
how Macro's work.
Can someone solve my problem?
Thanks in advance,
Anita