Combine three InputBoxes into one?
Hi again,
Am Sat, 24 May 2014 16:59:31 +0200 schrieb Claus Busch:
the code below is for universal use:
Sub TransformCol()
Dim Info As String
Dim LRow As Long, i As Long, j As Long
Dim arrOut As Variant
Dim arrInfo As Variant
Dim SourceCol As Long, TargetCol As Long
Info = Application.InputBox("Enter the number of rows," _
& "the source column and the target column comma separated", _
"Infos", Type:=2)
If Info = "" Or Info = "False" Then Exit Sub
arrInfo = Split(Info, ",")
SourceCol = Columns(UCase(arrInfo(1))).Column
TargetCol = Columns(UCase(arrInfo(2))).Column
With Sheets("Sheet2")
LRow = .Cells(Rows.Count, SourceCol).End(xlUp).Row
For i = 1 To LRow Step arrInfo(0)
arrOut = .Range(.Cells(i, SourceCol), _
.Cells(i + arrInfo(0) - 1, SourceCol))
Sheets("Sheet3").Cells(1, TargetCol + j) _
.Resize(rowsize:=arrInfo(0)) = arrOut
j = j + 1
Next
End With
End Sub
Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional
|