ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using cell value to reference another cell (https://www.excelbanter.com/excel-programming/372400-using-cell-value-reference-another-cell.html)

[email protected]

Using cell value to reference another cell
 
Hi,
I have a worksheet1 with the following contents:

Cell A1 = "C3"
Cell B1 = "123.45"
Cell A2 = "D5"
Cell B2 = "333.12"
Cell A3 = "B12"
Cell B3 = "34.99"
..
..
..


I would like to write a macro to move worksheet1 Cell B1("123.45") to
worksheet2 Cell C3 and move worksheet1 Cell B2("333.12") to worksheet2
Cell D5 ... and continue doing this until the last row with data is
encountered on worksheet1.


In other words use the contents of worksheet1, column A to determine
which Cell to reference on worksheet2.


Can someone help me with this?


John Fuller

Using cell value to reference another cell
 
This should work.

Sub Xfer()
Dim LastRow As Integer

LastRow = 3

For i = 1 To LastRow
Worksheets("Sheet2").Range(Worksheets("Sheet1"). _
Cells(i, 1).Value).Value = _
Worksheets("Sheet1").Cells(i, 2).Value
Next i
End Sub


wrote:
Hi,
I have a worksheet1 with the following contents:

Cell A1 = "C3"
Cell B1 = "123.45"
Cell A2 = "D5"
Cell B2 = "333.12"
Cell A3 = "B12"
Cell B3 = "34.99"
.
.
.


I would like to write a macro to move worksheet1 Cell B1("123.45") to
worksheet2 Cell C3 and move worksheet1 Cell B2("333.12") to worksheet2
Cell D5 ... and continue doing this until the last row with data is
encountered on worksheet1.


In other words use the contents of worksheet1, column A to determine
which Cell to reference on worksheet2.


Can someone help me with this?



Die_Another_Day

Using cell value to reference another cell
 
Sheets(2).Range(Sheets(1).Range("A1").Value) = Sheets(1).Range("B1")

HTH

Charles Chickering
wrote:
Hi,
I have a worksheet1 with the following contents:

Cell A1 = "C3"
Cell B1 = "123.45"
Cell A2 = "D5"
Cell B2 = "333.12"
Cell A3 = "B12"
Cell B3 = "34.99"
.
.
.


I would like to write a macro to move worksheet1 Cell B1("123.45") to
worksheet2 Cell C3 and move worksheet1 Cell B2("333.12") to worksheet2
Cell D5 ... and continue doing this until the last row with data is
encountered on worksheet1.


In other words use the contents of worksheet1, column A to determine
which Cell to reference on worksheet2.


Can someone help me with this?




All times are GMT +1. The time now is 07:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com