dolphinrob
New Member
- Joined
- Mar 2, 2009
- Messages
- 2
Hi, during work I use a Excel file with VBA. This file has been created by a person who earlier worked at our firm. This means that I doesnt have great knowledge regarding VBA.
After some adaptions of the file a macro which earlier worked now gives an error message.
The error is in a repeating (about 20x) macro part of another macro to fill a sheet with data.
The error is given by ActiveSheet.Paste.
I suspect that the error is due to "Begindem" which is changed position in worksheet after every paste (1 paste is being executed before error is given). The error message is: runtime error -2147417848 (80010108) method 'paste' of object '-worksheet; failed.
Sheets("Dtotal").Select
Range("Begindem").Select
ActiveSheet.Paste
Regels = Selection.Address(ReferenceStyle:=xlA1)
If Len(Regels) < 10 Then
laatste = Right(Regels, 1)
Else
If Len(Regels) < 12 Then
laatste = Right(Regels, 2)
Else
If Len(Regels) < 14 Then
laatste = Right(Regels, 3)
Else
laatste = Right(Regels, 4)
End If
End If
End If
Range("A" & laatste + 1).Select
ActiveWorkbook.Names.Add Name:="Begindem", RefersToR1C1:=Selection
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell
Hopefully someone can help me to solve this issue!
Thanks in advance
After some adaptions of the file a macro which earlier worked now gives an error message.
The error is in a repeating (about 20x) macro part of another macro to fill a sheet with data.
The error is given by ActiveSheet.Paste.
I suspect that the error is due to "Begindem" which is changed position in worksheet after every paste (1 paste is being executed before error is given). The error message is: runtime error -2147417848 (80010108) method 'paste' of object '-worksheet; failed.
Sheets("Dtotal").Select
Range("Begindem").Select
ActiveSheet.Paste
Regels = Selection.Address(ReferenceStyle:=xlA1)
If Len(Regels) < 10 Then
laatste = Right(Regels, 1)
Else
If Len(Regels) < 12 Then
laatste = Right(Regels, 2)
Else
If Len(Regels) < 14 Then
laatste = Right(Regels, 3)
Else
laatste = Right(Regels, 4)
End If
End If
End If
Range("A" & laatste + 1).Select
ActiveWorkbook.Names.Add Name:="Begindem", RefersToR1C1:=Selection
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell
Hopefully someone can help me to solve this issue!
Thanks in advance