Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 63
Default Worksheet change Macro part 2

I added some code to a macro Bob Phillips created, to copy in the orginal
data if one of the 32 cells were 0. The trouble I'm having is that if hit the
arrow key instead of return. The wrong column gets copied over. Any ideas on
how to get it to select the right cell each time? I'm sure it has to do with
my 'With target ' stmt, but I can't get it select the right cell ever if I do
that.

Thanks
Vick

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "L32,H32,F32" '<== change to suit
Dim cell As Range

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
For Each cell In Me.Range(Target.Offset(1, 0), Target.End(xlDown))

If IsNumeric(cell.Value) Then

cell.Value = cell.Value * (1 + .Value)
End If
Next cell
End With
End If

If Intersect(Target, Me.Range(WS_RANGE)) = 0 Then
With Target

ActiveCell.Offset(-29, 0).Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
ActiveCell.Offset(30, 0).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End With

End If

ws_exit:
Application.EnableEvents = True
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
Worksheet change Macro Question Vick Excel Discussion (Misc queries) 11 January 30th 08 03:09 PM
Macro to change part of cell Amy Excel Discussion (Misc queries) 2 August 2nd 07 12:43 PM
copy part of a worksheet into a worksheet in the same file/keepi. JTB Excel Worksheet Functions 1 September 23rd 06 09:13 AM
Running of Worksheet Change Macro breaks undo functionality. Rob Manger Excel Discussion (Misc queries) 1 April 6th 06 04:04 AM
Using this Automatic Resizing Macro with Worksheet Change [email protected] Excel Discussion (Misc queries) 0 December 19th 05 03:57 PM


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

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"