Thread: Wheres the bug
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
JE McGimpsey JE McGimpsey is offline
external usenet poster
 
Posts: 4,624
Default Wheres the bug

Looking at it again, this might be how I'd do it:


Public Sub Summary2()
Const sFNAME As String = "Summary"
Dim rDest As Range
Dim i As Long

With Application
.ScreenUpdating = False
.DisplayAlerts = False
On Error Resume Next
Worksheets(sFNAME).Delete
On Error GoTo 0
.DisplayAlerts = True
With Worksheets.Add(Worksheets(1))
.Name = sFNAME
Set rDest = .Range("A1")
End With
For i = Worksheets("Start").Index + 1 To _
Worksheets("End").Index - 1
With Worksheets(i)
If Left(.Range("P13").Text, 1) = "F" Then
.Range("P10:P38").Copy
With rDest
.PasteSpecial Paste:=xlPasteValues
.PasteSpecial Paste:=xlPasteFormats
End With
Set rDest = rDest(1, 2)
End If
End With
Next i
.ScreenUpdating = True
End With
End Sub




IIn article ,
"Bob Phillips" wrote:

Also testing the first two characters of a variable against a single
character does not seem smart. It will only succeed if myVal = F, in which
case you don't need the Left