VBA Newbie, Positioning according to R1C1 format

J

Jong

I am totally new to Excel VBA.
I have a Sheet1 containing Row number, Column number, and value(3columns).
For example,
Row number Column Number Value
----------- -------------- --------
2 6 23.1
4 13 31.9
6 4 51.0
.........
and so on.

I wish I could relocate the values(23.1, 31.9, 51.0... ) to the
corresponding cells(R1C1 format) on another sheet, for example, Sheet2 of
the same Excel book.
For example(Sheet2)
1 2 3 4 5 6 7 8 9 10 11 12 13
1
2 23.1
3
4
51.0
5
6 51.0
....

Would there be any elegant VBA program for doing this instead of Excel
function methods?

I really appreciate your help or suggestions to this.

Jong
 
J

Jong

Dear all,

Sorry for my typo in the example(Sheet2). On the Row4 and Column 13, '31.9'
should have been placed instead of '51.0.'

Thanks in advance,

Jong
 
J

Jong

Dear gurus,


I will appreciate it if you could give me any hints or key expressions for
the VBA program needed for completing this work.

Thanks in advance.
Jong
 
D

Dave Peterson

How about:

Option Explicit
Sub testme01()

Dim fromWks As Worksheet
Dim toWks As Worksheet

Dim FirstRow As Long
Dim LastRow As Long
Dim iRow As Long

Set fromWks = Worksheets("sheet1")
Set toWks = Worksheets("sheet2")

With fromWks
FirstRow = 2 '
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

On Error Resume Next
For iRow = FirstRow To LastRow
toWks.Cells(.Cells(iRow, "A").Value, .Cells(iRow, "B").Value) _
= .Cells(iRow, "C").Value
If Err.Number <> 0 Then
MsgBox "error with row: " & iRow
Err.Clear
End If
Next iRow
On Error GoTo 0
End With

End Sub
 
Top