View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Howard Howard is offline
external usenet poster
 
Posts: 536
Default Select Case code error


you don't need a SELECT CASE:



Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address < "$H$1" Then Exit Sub



Dim c As Range

Dim myRng As String



myRng = Target & "x"

For Each c In Range(myRng)

If c.Value < "" Then

c.Copy Range("I50").End(xlUp).Offset(1, 0)

c.Offset(0, 4).Copy Range("J50").End(xlUp).Offset(1, 0)

c.Offset(0, 5).Copy Range("K50").End(xlUp).Offset(1, 0)

End If

Next





Regards

Claus B.


Ah, yes. I see where you are going here.
Given the code I posted that works quite nice and is way more concise.

My bad is that the code I posted has further errors (not syntax, but rather as the code relates to the data.)

This offset only works with Swine which is in col A.
c.Offset(0, 4).Copy Range("J50").End(xlUp).Offset(1, 0)
c.Offset(0, 5).Copy Range("K50").End(xlUp).Offset(1, 0)

Dairy is in col B and the offsets should have been 3 and 4, Beef 2 and 3.

Sorry for the poor posting, but I am keeping the suggestion for further reference.

Thanks Claus.
Regards,
Howard