Thread: Compile Error
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
mypetduke mypetduke is offline
external usenet poster
 
Posts: 12
Default Compile Error

Thanks Mike You've helped me see I have a more fundamental code application
issue so I resubmitted a better question.

"Mike H" wrote:

Hi,

Maybe this

Set MyRange = Selection
For Each cell In MyRange
If Left(cell.Value, 5) = "GL Op" Then
cell.Value = Left(cell.Value, 5)
End If
If Left(cell.Value, 5) = "Au Op" Then
cell.Value = Left(cell.Value, 5)
End If
If Left(cell.Value, 5) = "WC Op" Then
cell.Value = Left(cell.Value, 5)
End If
If Left(cell.Value, 5) = "CA Op" Then
cell.Value = Left(cell.Value, 5)
End If
Next

Mike

"mypetduke" wrote:

I have the following code and keep getting a Compile error: For without Next.
Can anyone help.

Set myrange = ActiveSheet.Range(Selection, Selection.End(xlUp))
For Each cell In myrange
If Left(cell.Value, 5) = "GL Op" Then
cell.Cut
cell.Paste ("GL Op")
End If
If Left(cell.Value, 5) = "Au Op" Then
cell.Cut
cell.Paste ("Au Op")
End If
If Left(cell.Value, 5) = "WC Op" Then
cell.Cut
cell.Paste ("WC Op")
End If
If Left(cell.Value, 5) = "CA Op" Then
cell.Cut
cell.Paste ("Au Op")
End If

End Sub