Thread: Offset
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JLatham JLatham is offline
external usenet poster
 
Posts: 3,365
Default Offset

ActiveCell.offset(1,0).Range("A1").Select
to simply - that seems to work but sure is a strange statement.
ActiveCell.Offset(1,0).Select

Go through your code line by line and write down what it is doing and be
specific with sheet names and cell references and I think you'll see where
you may be having troubles.
Or set a break point or Stop command right before the
Range("U1").End(xlDown).Select statement and then use [F8] to single step
through the code to see exactly what it is doing.

I'm a bit confused as to what you are trying to copy from or put where. As
I understand it, you want to get some value from somewhere (via
Selection.Copy - but what cell/cells is that information in?) and then paste
it next to any entry in column T until it comes to a blank cell and then
quits. A blank cell where? In T? or over in column U, as I'm thinking
perhaps you're overwriting existing data in that column?

According to your code you're starting off in column U:
Range("U1").End(xlDown).Select
then inside of the Do loop you're copying the value there and moving down 1
row:
ActiveCell.Offset(1,0).Select
then you paste the data
but the
Loop Until IsEmpty...
statement is testing for what is in column V via .Offset(0, 1
If you want to look at column T, since you're in U, use
Loop Until IsEmpty(ActiveCell.Offset(0,-1))
The -1 will make it look 1 column to the LEFT instead of 1 column to the
right.

"DavidM" wrote:

Hi all

I've been trying to get this code to paste to the right of any data in
Column T until it comes to a blank cell, then stops.
I've changed the offset values yet cannot get it right. Help appreciated

Header in row 1
Data in Row 2

Application.Goto Reference:="R1C21"
Range("U1").End(xlDown).Select
Do
Selection.Copy
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Loop Until IsEmpty(ActiveCell.Offset(0, 1))
Selection.ClearContents
End Sub

Thank in Advance

Dave