how to set macro using cell location

  • Thread starter Thread starter namsilat
  • Start date Start date
N

namsilat

I have ten random values (text) in Column A from A1 to A10. On column
B, there are 10 numbers (between 1 to 10) arranged in random squence,
so B1 may be 4, B2 may be 8 and so on. On column C, I want to get the
value of the cell indicated by the NUMBER, such that if B1 is 4, then
in C1 I want to display the text from A4, if B2 is 8, I want to
display text from A8. Is it possible to set up a macro to utilize
that?
 
How about a worksheet formula:

Put this in C1 and drag down:
=INDEX($A$1:$A$10,B1)
 
and if you really need a macro, here's one way:

Option Explicit
Sub testme01()

Dim myRng As Range
Dim myCell As Range
With ActiveSheet
Set myRng = .Range("c1:c10")
For Each myCell In myRng.Cells
myCell.Value = .Range("a" & myCell.Offset(0, -1).Value)
Next myCell
End With
End Sub
 
Back
Top