Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default piece of code keeps failing....

Sub STEP1()

Dim FromWbook As Worksheet
Dim myCell As Range
Dim myRng1 As Range

Set FromWbook = Workbooks("Copy of 222.xls").Worksheets("Sheet2")

With FromWbook
Set myRng1 = .Range("E11:E71")
End With

For Each myCell In myRng1.Cells

If myCell.Value = myCell.Offset(3, 0) Then
myCell.Offset(0, 1).Value = 1
myCell.Offset(0, 1).Select
myCell.Offset(0, 1).Font.ColorIndex = 4

With Selection.Interior
.ColorIndex = 1
.Pattern = xlSolid
END WITH
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With

ElseIf myCell.Value < myCell.Offset(3, 0) Then
myCell.Offset(0, 1).Value = 1
myCell.Offset(0, 1).Select
myCell.Offset(0, 1).Font.ColorIndex = 4

With Selection.Interior
.ColorIndex = 1
.Pattern = xlSolid
END WITH
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Else
End If

Next myCell

End Sub

ssions.microsoft.com wrote in message
...
keep getting the error....

"compile error: Else without If"


Sub STEP1()

Dim FromWbook As Worksheet
Dim myCell As Range
Dim myRng1 As Range

Set FromWbook = Workbooks("Copy of 222.xls").Worksheets("Sheet2")

With FromWbook
Set myRng1 = .Range("E11:E71")
End With

For Each myCell In myRng1.Cells

If myCell.Value = myCell.Offset(3, 0) Then
myCell.Offset(0, 1).Value = 1
myCell.Offset(0, 1).Select
myCell.Offset(0, 1).Font.ColorIndex = 4

With Selection.Interior
.ColorIndex = 1
.Pattern = xlSolid
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With

ElseIf myCell.Value < myCell.Offset(3, 0) Then
myCell.Offset(0, 1).Value = 1
myCell.Offset(0, 1).Select
myCell.Offset(0, 1).Font.ColorIndex = 4

With Selection.Interior
.ColorIndex = 1
.Pattern = xlSolid
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Else
End If

Next myCell

End Sub


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
help with a piece of code Joseph Atie Excel Programming 5 December 23rd 08 05:05 AM
Interpretation of a piece of code FARAZ QURESHI Excel Discussion (Misc queries) 3 December 30th 07 11:29 PM
What is wrong with this vba piece of code? Jo[_2_] Excel Discussion (Misc queries) 4 October 4th 07 05:01 PM
Super piece of code..At least for me!! Arishy[_2_] Excel Programming 3 August 16th 05 04:20 PM
changing a piece of code Ajit Excel Programming 0 September 17th 04 02:45 PM


All times are GMT +1. The time now is 08:54 PM.

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

About Us

"It's about Microsoft Excel"