View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Stepping through Code

You are probably getting an error. Comment out the ON Error and see what
error you do get. Also put a break point in the ON Error routine. Your On
Error function could also have errors that need to be fixed.

"Jim May" wrote:

Sub SumRange()
Dim myCells As String
Dim wsn As Integer
Dim Wst As Worksheet
Dim answer As Double
Dim myRange As Range
Dim lrow As Long

On Error GoTo wsAdd
With Sheets("JimsSummary")
.Activate
.Cells.ClearContents ' Problem here !!!
End With
For Each Wst In Worksheets
If Left(Wst.Name, 3) = "Day" Then
CurrWs = Wst.Index
Wst.Select
Exit For
End If
Next
myCells = Application.InputBox("Enter Range to Sum", Type:=8).Address
If myCells = "" Then
'user hit cancel
Exit Sub
End If
'Sheets("Sheet1").Activate

Application.ScreenUpdating = False
Sheets("JimsSummary").Activate
rwct = 1

For DayNoSh = CurrWs To CurrWs + 30
Cells(rwct, 1) = Sheets(DayNoSh).Name
Set myRange = Sheets(DayNoSh).Range(myCells)
answer = Application.WorksheetFunction.Sum(myRange)
Cells(rwct, 2).Value = answer
rwct = rwct + 1
Next DayNoSh
'End If
lrow = Cells(Rows.Count, 2).End(xlUp).Row + 1
Range("B" & lrow).Formula = "=sum(B1:B" & (lrow - 1) & ")"
Range("B:B").NumberFormat = "0,000.00"

GoTo finish
wsAdd:
Sheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Name = "JimsSummary"
On Error GoTo 0
Resume Next
finish:
Application.ScreenUpdating = True
End Sub

TIA,
Jim

"JLatham" wrote:

Can we see all of the code, from Sub to End Sub?

"Jim May" wrote:

As I step thru the following code - after doing the F8 on the line:
.Cells.ClearContents (below) ,,, It Stops - the cursor remains on this
line - when I press F8 a second time the cursor jumps back to my Sub Name
Line 1

Any ideas what's happening?

With Sheets("JimsSummary")
.Activate
.Cells.ClearContents
End With