Hi,
Here is the same code commented
Posted - 04/06/2006 : 3:34:14 PM
--------------------------------------------------------------------------------
Hi,
This code may help you.
Sub Transposing()
Dim Table 'Table variable
Dim Target 'Target cell
Dim i As Integer, k As Integer, j As Integer
'*** Gets values to an table array (like excel table)
Table = Application.InputBox("Enter data", Type:=64)
'*** Gets target cell from user
Set Target = Application.InputBox("Enter target", Type:=8)
j = 0
'*** Looping through table array. Ubound 1 is the Upper Bound of first dimension
For i = 1 To UBound(Table, 1)
'*** Looping through table array. Ubound 2 is the Upper Bound of second dimension
For k = 1 To UBound(Table, 2)
'*** tests if there is a value
If Table(i, k) <> "" Then
'*** writes value to a cell
Target.Cells.Offset(j, 0) = Table(i, k)
'*** counter variable for cell offset from target cell
j = j + 1
End If
Next k
Next
End Sub
Hope this helps you to understand how the code works.
You can run the code step by step (F8) and follow the variables in Locals Window View-Locals Windows in editor
-vemaju
|