I cannot figure out why the following code won't execute...this is my code (without the long equations)...now i am not an expert...this was developed using bits and pieces that I found while searching through these forums...
the part that I am looking at right now is the section starting with "if unit = "" then"
I am using this to delete adjacent cells to the target cell when the target cell is deleted. But it is only doing the first two lines after the if statement. I don't know why, I am guessing it has something to do with the range(target.address) changing, but I am not for sure. This is the first time that I have really gotten into programming in VB and I am not quite sure how some of these things behave. Could someone please help!?


Public inMacro As Boolean

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo GetOut
If inMacro Then inMacro = False: Exit Sub
inMacro = True
If Target.Column = 3 And Target.Row <= 1000 Then
Set unit = Range(Target.Address)
'first part takes care of items deleted, if a unit is deleted then it deletes the rest of the row
If unit = "" Then
unit.Offset(0, -1) = ""
unit.Offset(0, 1) = "" '**********this is the where it stops w/o an error
unit.Offset(0, 2) = ""
unit.Offset(0, 3) = ""
Else
If unit.Offset(0, -1) = "" Then
unit.Offset(0, -1) = 1
If Left(unit, 1) = Worksheets("Remove Price").Cells(2, 4) Then 'Unit is a remove unit, so strip off "I" and look up the unit
unit.Offset(0, 1) = "long equation"
Else 'if unit doesn't have the I then it is assumed to be a install unit
If Left(unit, 1) = Worksheets("Install Price").Cells(2, 4) Then 'install unit is preceeded with "N"
unit.Offset(0, 1) = "long equation2"
Else 'If unit doesn't have an I or an N, then assumed to be an install unit
unit.Offset(0, 1) = "long Equation3"

End If
End If
End If
End If
End If

GetOut:
End
End Sub