Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Excel is no longer my friend. I have written some pretty cool code
(albeit of probably a very basic nature) and it sometimes works and sometimes does not. As far as a basic user such as myself can see there is absolutely no difference in the circumstances when it works and when it does not. Is there some sort of cache thing that needs to be cleared down (and can be through some code) that anyone knows of? Many thanks in advance. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
So are you going to show us your pretty cool code, or keep it a secret?
|
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sorry- my assumption is based on the fact that the code works sometimes
ergo there's nothing wrong with it but somthing wrong with some cache or some condition outside the code. Any idea about some sort of cache thing? If not I can paste the full code. Thanks. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
OK- it would make sense to put the Run-time error in I guess...
'-2147417848 (80010108)': Automation error THe object invoked has disconnected from its clients. Paha?? |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Start at the beginning. Post the code.
-- HTH RP (remove nothere from the email address if mailing direct) "solomon_monkey" wrote in message oups.com... Sorry- my assumption is based on the fact that the code works sometimes ergo there's nothing wrong with it but somthing wrong with some cache or some condition outside the code. Any idea about some sort of cache thing? If not I can paste the full code. Thanks. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub CashCheques()
' ' ' Application.ScreenUpdating = False result = MsgBox("Did you mean to press the 'CASH & CHEQUES' Button?", _ vbYesNoCancel, "CASH & CHEQUES") If result = vbYes Then GoTo continue Else MsgBox "'CASH & CHEQUES' cancelled", vbOKOnly, "CASH & CHEQUES" GoTo exit1 End If continue: Sheets("Monthly Receipts").Copy After:=Sheets(2) ActiveSheet.Unprotect Range("A9:E9").Select Selection.AutoFilter Selection.AutoFilter Field:=1 Selection.AutoFilter Selection.AutoFilter Dim num As Long Selection.AutoFilter Field:=5, Criteria1:="=" ActiveSheet.AutoFilter.Range.Select Range(Selection, Selection.End(xlDown)).Select Selection.EntireRow.Delete If Range("B9") = 0 Then MsgBox "No Cash transactions this period", vbOKOnly, "Cash" GoTo continue1 Else End If Range("A9:E9").Select If Range("B10") = 0 Then GoTo continue2 Else Range(Selection, Selection.End(xlDown)).Select End If continue2: Selection.Copy Sheets("Cash").Select Range("A9").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Application.CutCopyMode = False MsgBox Range("C4") & " Cash transactions this period", vbOKOnly, "Cash" continue1: Application.DisplayAlerts = False Sheets("Monthly Receipts (2)").Delete Application.DisplayAlerts = True Sheets("Cash").Select Dim rng As Range Set rng = Range("A7").End(xlDown) If rng = Range("A8") Then rng.Offset(1, 0).Select Else rng.Offset(0, 6).Select End If Sheets("Monthly Receipts").Copy After:=Sheets(3) ActiveSheet.Unprotect Range("A9:E9").Select Selection.AutoFilter Selection.AutoFilter Field:=1 Selection.AutoFilter Columns("E:E").Delete Selection.AutoFilter 'HERE Selection.AutoFilter Field:=5, Criteria1:="=" ActiveSheet.AutoFilter.Range.Select Range(Selection, Selection.End(xlDown)).Select Selection.EntireRow.Delete If Range("B9") = 0 Then MsgBox "No Cheque transactions this period", vbOKOnly, "Cheques" GoTo continue3 Else End If Range("A9:E9").Select If Range("B10") = 0 Then GoTo continue4 Else Range(Selection, Selection.End(xlDown)).Select End If If Range("B9") = 0 Then MsgBox "No Cheque transactions this period", vbOKOnly, "Cheques" GoTo continue3 Else End If Range("A9:E9").Select If Range("B10") = 0 Then GoTo continue4 Else Range(Selection, Selection.End(xlDown)).Select End If continue4: Selection.Copy Sheets("Cheques").Select Range("A9").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Application.CutCopyMode = False MsgBox Range("C4") & " Cheque transactions this period", vbOKOnly, "Cheques" continue3: Application.DisplayAlerts = False Sheets("Monthly Receipts (2)").Delete Application.DisplayAlerts = True Sheets("Cheques").Select Dim rng2 As Range Set rng2 = Range("A7").End(xlDown) If rng2 = Range("A8") Then rng2.Offset(1, 0).Select Else rng2.Offset(0, 6).Select End If Sheets("Monthly Receipts").Select exit1: Sheets("Monthly Receipts").Select Application.ScreenUpdating = True End Sub I have indicated where it runs the error. It is the second time I copy the same worksheet. I do not understand why it does not always work or always fail. |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try qualifying all of your ranges by explicitly including the worksheet.
Not doing so is asking for problems. Tim -- Tim Williams Palo Alto, CA "solomon_monkey" wrote in message oups.com... Sub CashCheques() ' ' ' Application.ScreenUpdating = False result = MsgBox("Did you mean to press the 'CASH & CHEQUES' Button?", _ vbYesNoCancel, "CASH & CHEQUES") If result = vbYes Then GoTo continue Else MsgBox "'CASH & CHEQUES' cancelled", vbOKOnly, "CASH & CHEQUES" GoTo exit1 End If continue: Sheets("Monthly Receipts").Copy After:=Sheets(2) ActiveSheet.Unprotect Range("A9:E9").Select Selection.AutoFilter Selection.AutoFilter Field:=1 Selection.AutoFilter Selection.AutoFilter Dim num As Long Selection.AutoFilter Field:=5, Criteria1:="=" ActiveSheet.AutoFilter.Range.Select Range(Selection, Selection.End(xlDown)).Select Selection.EntireRow.Delete If Range("B9") = 0 Then MsgBox "No Cash transactions this period", vbOKOnly, "Cash" GoTo continue1 Else End If Range("A9:E9").Select If Range("B10") = 0 Then GoTo continue2 Else Range(Selection, Selection.End(xlDown)).Select End If continue2: Selection.Copy Sheets("Cash").Select Range("A9").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Application.CutCopyMode = False MsgBox Range("C4") & " Cash transactions this period", vbOKOnly, "Cash" continue1: Application.DisplayAlerts = False Sheets("Monthly Receipts (2)").Delete Application.DisplayAlerts = True Sheets("Cash").Select Dim rng As Range Set rng = Range("A7").End(xlDown) If rng = Range("A8") Then rng.Offset(1, 0).Select Else rng.Offset(0, 6).Select End If Sheets("Monthly Receipts").Copy After:=Sheets(3) ActiveSheet.Unprotect Range("A9:E9").Select Selection.AutoFilter Selection.AutoFilter Field:=1 Selection.AutoFilter Columns("E:E").Delete Selection.AutoFilter 'HERE Selection.AutoFilter Field:=5, Criteria1:="=" ActiveSheet.AutoFilter.Range.Select Range(Selection, Selection.End(xlDown)).Select Selection.EntireRow.Delete If Range("B9") = 0 Then MsgBox "No Cheque transactions this period", vbOKOnly, "Cheques" GoTo continue3 Else End If Range("A9:E9").Select If Range("B10") = 0 Then GoTo continue4 Else Range(Selection, Selection.End(xlDown)).Select End If If Range("B9") = 0 Then MsgBox "No Cheque transactions this period", vbOKOnly, "Cheques" GoTo continue3 Else End If Range("A9:E9").Select If Range("B10") = 0 Then GoTo continue4 Else Range(Selection, Selection.End(xlDown)).Select End If continue4: Selection.Copy Sheets("Cheques").Select Range("A9").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Application.CutCopyMode = False MsgBox Range("C4") & " Cheque transactions this period", vbOKOnly, "Cheques" continue3: Application.DisplayAlerts = False Sheets("Monthly Receipts (2)").Delete Application.DisplayAlerts = True Sheets("Cheques").Select Dim rng2 As Range Set rng2 = Range("A7").End(xlDown) If rng2 = Range("A8") Then rng2.Offset(1, 0).Select Else rng2.Offset(0, 6).Select End If Sheets("Monthly Receipts").Select exit1: Sheets("Monthly Receipts").Select Application.ScreenUpdating = True End Sub I have indicated where it runs the error. It is the second time I copy the same worksheet. I do not understand why it does not always work or always fail. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|