View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Yossy Yossy is offline
external usenet poster
 
Posts: 127
Default Referencing two types of sheets - I get Error HELP!!

I am referencing two types of named sheet(s) in a work book. One named with
_Bal and the others named _Trial but I get error. What am I doing wrong. All
help totally appreciated. THanks

Sub T_Bal()
Dim ws As Worksheet
Application.ScreenUpdating = False
For Each ws In Worksheets
If InStr(1, ws.Name, "_Bal") Then
With ws
.Range("g35").Value = .Range("g40").Value
With .Range("g23")
formStr = .Formula
.Formula = formStr & "+" & ws.Range("g36").Value
End With
With .Range("g30")
formStr = .Formula
.Formula = formStr & "+" & ws.Range("g57").Value
End With
.Range("g57").Value = 0
End With
ElseIf InStr(1, ws.Name, "_Trial") Then
With ws
.Range ("g23")
formStr = .Formula
.Formula = formStr & "+" & ws.Range("g36").Value
End With
End If
Next
Application.ScreenUpdating = True
End Sub