move cursor in excle using macro

F

fdibbins

ok, sounds dumb, but how do I move the cursor in excel a set number of lines
using a macro - cant use a cell reference because it changes all the time. I
need to cut an item in 1 cell, move down 2 lines, past it and then "enddown"
to find the next instance. I have 100's of these to do, and number of lines
between each cut/paste is never the same. I know its really simple, but just
cant seem to get it working...help please!!!!
 
F

FSt1

hi
activecell.cut destination:=activecell.offset(2,0)
activecell.end(xldown).activate

but if the number of rows between the cut and paste is never the same, i
can't see how this will do much good other than show you the syntax.

Regards
FSt1
 
D

Don Guillett

I don't like selections but try this. Change "a" to your column.

Sub cuttworowsdown()
cells(Rows.Count, "a").End(xlUp).Select
Do Until ActiveCell.Row = 1
ActiveCell.Cut ActiveCell.Offset(2)
ActiveCell.End(xlUp).Select
Loop
End Sub
 
F

fdibbins

Thanks a bunch, works great. The cut/paste distance remains the same, just
the distance to the next "set" changes, so an .end(xldown) works well for
that too.

If i wanted to just move to a cell x lines down (or x colums across), what
part of this command would do that?

ActiveCell.Cut Destination:=ActiveCell.Offset(1, 0)
ActiveCell.End(xlDown).Activate

and thanks for the really fast reply :)
 
F

FSt1

hi,
the offset part.
offset(x,y) where x = row and y = columns
postive x = rows down, negative x = rows up
postive y = columns left and negative = columns right

read up on it in vb help

Regards
FS1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top