Using relative references in macro

  • Thread starter Thread starter Cinco
  • Start date Start date
C

Cinco

I want to move the contents of a cell (in an array) when I know its column
and relative row number. The requested cell (date & time format) is in
Column D and its relative row # is in cell E5. I want to move the contents
of this cell to cell B1. The following is a sample of the table:

Col D
7/16/2009 23:23:57
7/17/2009 4:10:07
7/17/2009 5:40:25
7/17/2009 20:58:30
7/17/2009 23:22:49
7/18/2009 3:00:51
7/18/2009 5:58:52

I've tried various approaches to specify the relative cell's location so I
can move its contents but with no success. Help. Thanks for your assistance.
Jim
 
If I understand your question correctly, try this...

Range("B1").Value = Cells(Range("E5").Value, "D").Value
 
Rick,

It does what I want except I am 1 row low re the contents that I want to
move. How do I change your command to move the contents of my relative row #
+1? Thanks again for your help. BTW, all my attempts were much more
complicated than the simple one line solution that you provided, and none of
mine worked.
Jim
 
Do you mean you want to add one to whatever is in E5? Is so...

Range("B1").Value = Cells(Range("E5").Value + 1, "D").Value
 
Back
Top