Hello all,
I have a document that I frequently use for making calculations for quotations. I always use the same formulas in each line for this document with different operations in the columns.
To have an overview, I have split these enumerations into phases and subphases. To avoid errors, I wrote a macro that copies these formulas from a hidden sheet. Also the lay-out is copied from this document.
Because of my pour programming skills, this macro is pretty sluggisch.
The document in general is OK for me, but now some colleagues of mine also want to use this program. It was never intended for someone else to use and isn't fool proof.
Can someone help me to make this more reliable?
This is for example the macro I use for inserting a new row:
Sub Lijn_Invoegen()
'
'
Application.ScreenUpdating = False
Application.CutCopyMode = False
If Not ActiveCell.Borders(xlEdgeBottom).LineStyle = xlLineStyleNone Then MsgBox "U kan hier geen lijnen invoegen. Gelieve op een blauw vakje te gaan staan"
If Not ActiveCell.Borders(xlEdgeBottom).LineStyle = xlLineStyleNone Then GoTo Handlecancel
Sheets("Voorbereidingsblad").Unprotect
Dim Rng
Rng = InputBox("Geef het aantal benodigde rijen in.")
On Error GoTo Handlecancel
Range(ActiveCell.Offset(0, 0), ActiveCell.Offset(Rng - 1, 0)).Select
Selection.EntireRow.Insert
ActiveCell.Rows("1:1").EntireRow.Select
ActiveCell.Offset(0, 9).Range("A1").Select
Range(ActiveCell.Offset(0, 0), ActiveCell.Offset(Rng - 1, 6)).Select
Sheets("Basis").Visible = True
Sheets("Basis").Select
Range("A1").Select
ActiveCell.Range("j10:P10").Select
Selection.Copy
Sheets("Voorbereidingsblad").Select
Selection.PasteSpecial Paste:=xlFormulas, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
ActiveCell.Offset(0, -7).Range("A1").Select
Application.CutCopyMode = False
ActiveCell.Offset(Rng, 0).Range("A1").Select
Range(ActiveCell.Offset(0, 0), ActiveCell.Offset(0, 6)).Select
Selection.Copy
Range(ActiveCell.Offset(-1, 0), ActiveCell.Offset(-Rng, 6)).Select
Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
ActiveCell.Select
Application.CutCopyMode = False
Handlecancel:
Sheets("Basis").Visible = False
If Err = 13 Then
MsgBox "U heeft geanulleerd."
End If
'Sheets("Voorbereidingsblad").Protect
End Sub
PS: How can I show the XLS file?
I have a document that I frequently use for making calculations for quotations. I always use the same formulas in each line for this document with different operations in the columns.
To have an overview, I have split these enumerations into phases and subphases. To avoid errors, I wrote a macro that copies these formulas from a hidden sheet. Also the lay-out is copied from this document.
Because of my pour programming skills, this macro is pretty sluggisch.
The document in general is OK for me, but now some colleagues of mine also want to use this program. It was never intended for someone else to use and isn't fool proof.
Can someone help me to make this more reliable?
This is for example the macro I use for inserting a new row:
Sub Lijn_Invoegen()
'
'
Application.ScreenUpdating = False
Application.CutCopyMode = False
If Not ActiveCell.Borders(xlEdgeBottom).LineStyle = xlLineStyleNone Then MsgBox "U kan hier geen lijnen invoegen. Gelieve op een blauw vakje te gaan staan"
If Not ActiveCell.Borders(xlEdgeBottom).LineStyle = xlLineStyleNone Then GoTo Handlecancel
Sheets("Voorbereidingsblad").Unprotect
Dim Rng
Rng = InputBox("Geef het aantal benodigde rijen in.")
On Error GoTo Handlecancel
Range(ActiveCell.Offset(0, 0), ActiveCell.Offset(Rng - 1, 0)).Select
Selection.EntireRow.Insert
ActiveCell.Rows("1:1").EntireRow.Select
ActiveCell.Offset(0, 9).Range("A1").Select
Range(ActiveCell.Offset(0, 0), ActiveCell.Offset(Rng - 1, 6)).Select
Sheets("Basis").Visible = True
Sheets("Basis").Select
Range("A1").Select
ActiveCell.Range("j10:P10").Select
Selection.Copy
Sheets("Voorbereidingsblad").Select
Selection.PasteSpecial Paste:=xlFormulas, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
ActiveCell.Offset(0, -7).Range("A1").Select
Application.CutCopyMode = False
ActiveCell.Offset(Rng, 0).Range("A1").Select
Range(ActiveCell.Offset(0, 0), ActiveCell.Offset(0, 6)).Select
Selection.Copy
Range(ActiveCell.Offset(-1, 0), ActiveCell.Offset(-Rng, 6)).Select
Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
ActiveCell.Select
Application.CutCopyMode = False
Handlecancel:
Sheets("Basis").Visible = False
If Err = 13 Then
MsgBox "U heeft geanulleerd."
End If
'Sheets("Voorbereidingsblad").Protect
End Sub
PS: How can I show the XLS file?
Last edited: