Hi,
I have a macro to open files -> copy data from a1:b800 -> put it to general file and doing solver function. But when I'm start a macro I'm get back information "Run-time error '1004': Microsoft Excel cannot paste the data." Frequency of this message is 80% of time when I'm start a macro.
I don't know what I need to do to solved this problem.
Below You can see part of the code:
When I'm click the debug then VBA marks me first line with "ActiveSheet.Paste". When macro do it (this "ActiveSheet.Paste") then finish all lines on a macro. If You need more information about the macro code then I can explain.
Regards
Ksar87
I have a macro to open files -> copy data from a1:b800 -> put it to general file and doing solver function. But when I'm start a macro I'm get back information "Run-time error '1004': Microsoft Excel cannot paste the data." Frequency of this message is 80% of time when I'm start a macro.
I don't know what I need to do to solved this problem.
Below You can see part of the code:
Code:
Sub bijsteladvies()
Application.ScreenUpdating = False
Application.DisplayAlerts = False '
' CHECK OR IMPORT DATA IS GOOD
If Not (Range("checkdata")) Then
MsgBox ("Well good to fill all data !!!!!!!!")
GoTo Lastline:
End If
' CHECK THAT EXISTS FILE WITH LAMP NUMBER
Dim Search_file_name As String, Found_file_name As String
Search_file_name = Range("subdirectory") & Range("lampnur") & "*.*"
Found_file_name = Dir(Search_file_name)
If Found_file_name = "" Then
MsgBox ("lamp number not found")
GoTo Lastline:
End If
Range("naam") = Range("subdirectory") & Found_file_name
' OPENEN FILE
Workbooks.OpenText Filename:=Range("naam"), Origin:= _
xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=True, Semicolon:=False, _
Comma:=False, Space:=True, Other:=False, FieldInfo:=Array(Array(1, 1), _
Array(2, 1)), ThousandsSeparator:=","
'COPYING DATA to "bijstel file"
Range("a1:a800").Select
Selection.Copy
ActiveWindow.Close
Range("s2").Select
ActiveSheet.Paste
' OPENEN FILE
Workbooks.OpenText Filename:=Range("naam"), Origin:= _
xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=True, Semicolon:=False, _
Comma:=False, Space:=True, Other:=False, FieldInfo:=Array(Array(1, 1), _
Array(2, 1)), ThousandsSeparator:=","
'COPYING DATA to"bijstel file"
Range("b1:b800").Select
Selection.Copy
ActiveWindow.Close
Range("t2").Select
ActiveSheet.Paste
...
When I'm click the debug then VBA marks me first line with "ActiveSheet.Paste". When macro do it (this "ActiveSheet.Paste") then finish all lines on a macro. If You need more information about the macro code then I can explain.
Regards
Ksar87