View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Don Lloyd Don Lloyd is offline
external usenet poster
 
Posts: 119
Default autofill or copy & paste "till a value"

Hi,

Sub CopyData()
Dim Rw, V, Rnge
V = Range("E1").Value
Rw = 0
Do
Rw = Rw + 1
Loop Until Cells(Rw, 2) = V
Rnge = "A1:D" & Rw
Range(Rnge).Copy Sheets("Sheet2").Range("A1")
End Sub

The value in E1 is stored in V. The DO loop goes down the rows looking for V
in column 2 (B)
It adds Rw to the end of Rnge, copies the range to sheet 2, A!.

Don

"uriel78" wrote in message
...
Hello, perhaps a simple problem...but...:-(

I've got four columns (A B C D) of data in sheet 1. In columns B there are
increasing value (integer 1,2,3,4,5...200)

In sheet one, in cell E1 there is number (that comes from other data), for
example "78"

Now, in sheet 2 I need to do sthg as "copy & paste" columns from A to D of
sheet1 but only if B values are <=E1....

How can I do this in Vba...??
Actually I copy the A1:D1 range and, by using an if statement (if
B1<=$E1$1)
autofill down columns...but I can't "stop" automatically the autofill
function....

If possible I wish to use a "for" routine (so that I can understand to
solve
other similar problems by myself...)

Thanks in advance...!