View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default Combine three InputBoxes into one?

Hi Howard,

Am Sat, 24 May 2014 06:05:08 -0700 (PDT) schrieb L. Howard:

1. Combine all three entries to a single inputbox, say comma delimited.
2. When referring to the source and destination columns use a letter. (Code below uses a letter for Source and a "number - 1" for Destination column.)


try:

Sub TransformCol()
Dim Info As String
Dim LRow As Long, i As Long, j As Long
Dim arrOut As Variant
Dim arrInfo As Variant

Info = Application.InputBox("Enter the number of rows," _
& "the source column and the target column comma separated",
"Infos", _
Type:=2)

arrInfo = Split(Info, ",")

With Sheets("Sheet2")
LRow = .Cells(Rows.Count, arrInfo(1)).End(xlUp).Row
For i = 1 To LRow Step arrInfo(0)
arrOut = .Range(.Cells(i, UCase(arrInfo(1))), _
.Cells(i + arrInfo(0) - 1, UCase(arrInfo(1))))
Sheets("Sheet3").Cells(1, Asc(UCase(arrInfo(2))) + j - 64) _
.Resize(rowsize:=arrInfo(0)) = arrOut
j = j + 1
Next
End With
End Sub

Enter the informations comma separated but without space


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional