[VBA] Abraca Dabra's Question
Option Explicit
Sub main()
Dim horizontalCell As Range
Dim verticalCell As Range
Dim verticalRange As Range
Dim horizontalRange As Range
Dim i As Integer 'myVeritcalCounter
Dim j As Integer 'myhorizontalCounter
i = 1
'To clear output sheet first
ThisWorkbook.Worksheets("2.output").Cells.Clear
With ThisWorkbook.Worksheets("1.input")
Set verticalRange = .Range(.Cells(2, 1), .Cells(2, 1).End(xlDown))
Set horizontalRange = .Range(.Cells(1, 2), .Cells(1, 2).End(xlToRight))
End With
For Each verticalCell In verticalRange
For Each horizontalCell In horizontalRange
With ThisWorkbook.Worksheets("2.output")
.Cells(i, 1).Value = verticalCell.Value
.Cells(i, 2).Value = horizontalCell.Value
.Cells(i, 3).Value = ThisWorkbook.Worksheets("1.input").Cells(verticalCell.Row, horizontalCell.Column)
i = i + 1
End With
Next horizontalCell
Next verticalCell
Set verticalRange = Nothing
Set horizontalRange = Nothing
MsgBox "Done. The output is in Sheet [2.output] now"
End Sub
Source: ---
Disclaimer: The information in this webpage is shared by anonymous users from external online sources. We cannot guarantee its accuracy or truthfulness. Users should exercise caution and verify information independently.