I'm looking for a way to put data into 1 column from 2 different columns, alternating every other row.
The data looks like this:
A B C
1 2
3 4
5 6
And I want C to look like this:
C
1
2
3
4
5
6
I don't necessarily need to keep the data in columns A and B, as long as C follows this format.
Thanks!
**
Excellent, just what I was looking for. I couldn't get the UDF working right, I'll try messing around with it, but the Index solution works great!
--Thanks
Last edited by Cauthon; 08-12-2010 at 03:11 PM. Reason: Solved
Assuming your values commence in A1 then one way
C1:
=INDEX($A:$B,CEILING(ROWS(C$1:C1)/2,1),2-MOD(ROWS(C$1:C1),2))
copied down
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
I may late but this one is UDF solution.
Function MERGECOLS(rng As Range) As Variant Dim r, c, CallerRows, CallerCols, iCount As Integer Dim TempStr As String Dim Result(), cValue As Variant For c = 1 To rng.Columns.Count For r = 1 To rng.Rows.Count iCount = iCount + 1 TempStr = TempStr & " " & Cells(r, c) Next r Next c With Application.Caller CallerRows = .Rows.Count CallerCols = .Columns.Count End With If CallerRows > iCount Or CallerCols > 1 Then MERGECOLS = "#RANGE!" Exit Function End If cValue = Split(TempStr, " ") ReDim Result(1 To CallerRows, 1 To CallerCols) For r = 1 To UBound(cValue) Result(r, 1) = cValue(r) Next r MERGECOLS = Result End FunctionSelect whole range C1:C6, press F2 then paste this formula thereA B Result 1 4 1 2 5 2 3 6 3 4 5 6
=MERGECOLS(A2:B4)
Confirm with Ctrl+Shift+Enter.
Last edited by contaminated; 08-12-2010 at 02:00 PM.
Люди, питающие благие намерения, как раз и становятся чудовищами.
Regards, «Born in USSR»
Vusal M Dadashev
Baku, Azerbaijan
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks