Wheres the bug

G

Guest

Hi gang
Here's my cod
Sub summary2(

Application.ScreenUpdating = Tru
Dim i As Intege
Dim myVal As Strin
On Error Resume Nex
Application.DisplayAlerts = Fals
Worksheets("Summary").Delet
Application.DisplayAlerts = Tru
Worksheets.Add(Worksheets(1)).Name = "Summary
For i = Worksheets("Start").Index + 1 To Worksheets("End").Index -
myVal = Worksheets(i).Range("P13").Tex
If Left(myVal,2) = "F
Then Worksheets(i).Selec
Range("P10:p38").Cop
Worksheets("Summary").Selec
Range("IV1").End(xlToLeft)(1, 2).Selec
Selection.PasteSpecial Paste:=xlPasteValue
Selection.PasteSpecial Paste:=xlPasteFormat
'End I
Next

Im getting a syntax error on ....If Left(myVal,2) = "F
Wheres the bug

Thanks!
 
J

JE McGimpsey

The Syntax is If...Then

Your line is split. Either joint it with the " _" (space-underscore)
compiler directive, or move the following line up to read

If Left(myVal,2) = "F" Then Worksheets(i).Select
 
D

Don Guillett

Besides the then being on the line below, you should be asking about case
and 1 vs 2 for F.
If ucase(Left(myVal,1)) = "F"
Also, why delete the summary sheet - just to re-create. why not
Worksheets("Summary").usedrange.clear
or something like it?
Also, try to remove selecting

worksheets(i).range("P10:p38").Copy
with Worksheets("Summary").Range("IV1").End(xlToLeft)(1, 2)
.PasteSpecial Paste:=xlPasteValues
.PasteSpecial Paste:=xlPasteFormats
end with
end if
 
G

Guest

Hi Do
Thanks for the respons
I am deleting an existing summary and adding the new one that I have created
Maybe I should be copying over the old data. Just felt safer deleting i
Thanks again!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top