Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Wheres the bug

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!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Wheres the bug

If needs a Then

If Left(myVal,2) = "F" Then
Worksheets(i).Select
Range("P10:p38").Copy
Worksheets("Summary").Select
Range("IV1").End(xlToLeft)(1, 2).Select
Selection.PasteSpecial Paste:=xlPasteValues
Selection.PasteSpecial Paste:=xlPasteFormats
End If


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Catherine" wrote in message
...
Hi gang!
Here's my code
Sub summary2()

Application.ScreenUpdating = True
Dim i As Integer
Dim myVal As String
On Error Resume Next
Application.DisplayAlerts = False
Worksheets("Summary").Delete
Application.DisplayAlerts = True
Worksheets.Add(Worksheets(1)).Name = "Summary"
For i = Worksheets("Start").Index + 1 To Worksheets("End").Index - 1
myVal = Worksheets(i).Range("P13").Text
If Left(myVal,2) = "F"
Then Worksheets(i).Select
Range("P10:p38").Copy
Worksheets("Summary").Select
Range("IV1").End(xlToLeft)(1, 2).Select
Selection.PasteSpecial Paste:=xlPasteValues
Selection.PasteSpecial Paste:=xlPasteFormats
'End If
Next i

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

Thanks!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Wheres the bug

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

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Bob Phillips" wrote in message
...
If needs a Then

If Left(myVal,2) = "F" Then
Worksheets(i).Select
Range("P10:p38").Copy
Worksheets("Summary").Select
Range("IV1").End(xlToLeft)(1, 2).Select
Selection.PasteSpecial Paste:=xlPasteValues
Selection.PasteSpecial Paste:=xlPasteFormats
End If


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Catherine" wrote in message
...
Hi gang!
Here's my code
Sub summary2()

Application.ScreenUpdating = True
Dim i As Integer
Dim myVal As String
On Error Resume Next
Application.DisplayAlerts = False
Worksheets("Summary").Delete
Application.DisplayAlerts = True
Worksheets.Add(Worksheets(1)).Name = "Summary"
For i = Worksheets("Start").Index + 1 To Worksheets("End").Index - 1
myVal = Worksheets(i).Range("P13").Text
If Left(myVal,2) = "F"
Then Worksheets(i).Select
Range("P10:p38").Copy
Worksheets("Summary").Select
Range("IV1").End(xlToLeft)(1, 2).Select
Selection.PasteSpecial Paste:=xlPasteValues
Selection.PasteSpecial Paste:=xlPasteFormats
'End If
Next i

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

Thanks!





  #4   Report Post  
Posted to microsoft.public.excel.programming
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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Wheres the bug

Thanks for all of the response
If Left(.Range("P13").Text, 1) = "F" The

Im new to programming and dont follow all the statement. The contents of p13 is a concatenation that my user is using. The second place (F) are the transaction that should be included in the summary. With your statement, how is it evaluated if there is an F some where else in the cell contents
Thank
Cat



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Wheres the bug

See reply to your previous post.

In article ,
Catherine wrote:

Hi gang!
Here's my code
Sub summary2()

Application.ScreenUpdating = True
Dim i As Integer
Dim myVal As String
On Error Resume Next
Application.DisplayAlerts = False
Worksheets("Summary").Delete
Application.DisplayAlerts = True
Worksheets.Add(Worksheets(1)).Name = "Summary"
For i = Worksheets("Start").Index + 1 To Worksheets("End").Index - 1
myVal = Worksheets(i).Range("P13").Text
If Left(myVal,2) = "F"
Then Worksheets(i).Select
Range("P10:p38").Copy
Worksheets("Summary").Select
Range("IV1").End(xlToLeft)(1, 2).Select
Selection.PasteSpecial Paste:=xlPasteValues
Selection.PasteSpecial Paste:=xlPasteFormats
'End If
Next i

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

Thanks!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel: wheres menu item to change file format conversion options? Serge Excel Discussion (Misc queries) 1 December 14th 05 08:55 PM
Wheres the bug Catherine[_5_] Excel Programming 4 April 26th 04 07:36 PM


All times are GMT +1. The time now is 02:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"