Using relative references in macro

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
 
R

Rick Rothstein

If I understand your question correctly, try this...

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

Cinco

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
 
R

Rick Rothstein

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
 

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