PDA

View Full Version : Code Error's



KK1966
02-04-2009, 02:07 AM
Hi
I have code below, but it was error’s, I have try many thing to solve it but nothing ok!!

Can someone help?? The intents that’s the range A36 to down if value >1 then the COL B same the cells would equal to cell H1”

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Range(Target.Address), Range("A36:A" & Range("A36").End(xlDown).Row) Is Nothing And Target.Value > 1 Then
Target.Offset(0,1).Value = Range("H1")
End If
End Sub

GTO
02-04-2009, 03:17 AM
Greetings kk,

If I understand what you are trying to get done, I think you want to use the Change event.

'// I think you want the Change event, rather than the SelectionChange event. See, //
'// in SelectionChange, the Target is the cell you land on (which of course could //
'// be empty). Conversely, in the Change event, the Target is the cell or cells //
'// that just changed. //
Private Sub Worksheet_Change(ByVal Target As Range)
'// Also note the change in how we find the last row. You had it only looking //
'// from A36 down til it finds a change. You probably want it to look "up" //
'// from the last row, til it finds the end of the range you're using. //
If Not Intersect(Target, Range("A36:A" & Cells(Rows.Count, 1).End(xlUp).Row)) _
Is Nothing _
And Target.Value > 1 Then
'// So we don't recurse//
Application.EnableEvents = False
Target.Offset(0, 1).Value = Range("H1").Value
Application.EnableEvents = True
End If
End Sub

Hope we're "on the same page" and that this helps,

Mark