Formula or Macro to place data in one row

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,363
Office Version
  1. 2021
Platform
  1. Windows
I have the following data below, I need a formula or macro to copy display these in one row



Excel 2012
ABCDE
1KM-203KM-206
2KM-003KM-006
3KM-023KM-026
4KM-163KM-166
5KM-083KM-086
6KM-093KM-096
7KM-103KM-106
8KM-183KM-186
9KM-123KM-126
10KM-143KM-146
11KM-063KM-066
12KM-043KM-046
13KM-303KM-306
14KM-003KM-006
15KM-053KM-056
16KM-031KM-032KM-033KM-034KM-035
Sheet1
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

admiral100

Well-known Member
Joined
Jan 17, 2015
Messages
873
Hi,

Found that on the web ...

Sub MergeListUniques()
Dim R As Long, C As Long, Data As Variant
'change your range as needed
Data = Range("A1:E" & Cells.Find("*", , xlValues, , xlRows, xlPrevious).Row)
With CreateObject("Scripting.Dictionary")
For C = 1 To UBound(Data, 2)
For R = 1 To UBound(Data, 1)
If Len(Trim(Data(R, C))) Then .Item(Data(R, C)) = Data(R, C)
Next
Next
Columns("F").ClearContents
Range("F3").Resize(.Count) = Application.Transpose(.Items)
End With
End Sub
 
Upvote 0

admiral100

Well-known Member
Joined
Jan 17, 2015
Messages
873
and that for one row :)

Sub CopytoOneRow()
Dim myArr As Variant
Dim i As Integer
Dim j As Integer
Dim k As Integer, l As Integer
Dim lc As Integer
Dim sh As Worksheet

Set sh = Sheets("Sheet2") ' change where you want the input
lc = Range("IV1").End(xlToLeft).Column
l = 1
myArr = Range("A1").CurrentRegion
For i = 1 To lc
k = 1
For j = LBound(myArr) To UBound(myArr)
sh.Cells(2, l) = myArr(k, i)
k = k + 1
l = l + 1
Next j
Next i
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,191,025
Messages
5,984,197
Members
439,877
Latest member
kellylet

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top