Hey,
I work for an accountancy firm which uses a bookkeeping package incorporated into Microsoft Excel via Visual Basic. We have been having a problem when we attempt to balance forward to the next accounting year. It is at this stage that we receive the Run-time error message 1004. It relates to the following piece of code;
Public Sub keep_osItems()
'Copies o/s items to month 0.
Dim diff As Long, i As Long, n As Long
clear_dataEnquiry
vFilter searchColumn:=7, viewRange:=Range("allTxns"), anyValue:=True
Range("dataEnquiry").Sort Range("enquiryStart").Offset(0, 10)
diff = (Range("enquiryEnd").row - Range("enquiryStart").row) - (Range("obEnd").row - Range("obStart").row) + 2
If diff > 0 Then
n = Range("obEnd").row - 1
For i = 1 To diff
Rows(n).EntireRow.Insert
Range("M" & n).Formula = "=M" & ActiveCell.row - 1
Next
monthsDown Range("obStart").row + 1
End If
Range("B" & Range("enquiryStart").row, "I" & Range("enquiryEnd").row).Copy destination:=Range("obStart").Offset(2)
End Sub
The problematic piece of code highlighted by Visual Basic in debug mode is;
diff = (Range("enquiryEnd").row - Range("enquiryStart").row) - (Range("obEnd").row - Range("obStart").row) + 2
My knowledge of Visual Basic is school level standard and was wondering if anyone would know what the problem is.
Thanks in advance.
Bookmarks