Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default how to copy every nth column of a row to the first cell of the row?

How do you copy every nth column of a row to the first cell of the row?


The values in the columns are string values and I'd like to place a
space between every value as it's inserted into the cell.

There are thousands of columns (using excel 2007) and each row is using
a different number of columns, so the macro will need to figure out
when the last column of data is in the row and stop at that point.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default how to copy every nth column of a row to the first cell of the row?

Here's one quick way to do it - create a User defined function:

Public Function EveryNth(Spacing As Range, source As Range) As String
Dim bytCounter As Byte
Dim strTemp As String
Set source = Intersect(source, Application.Caller.EntireRow)
If Not (source Is Nothing) Then
Set source = Range(source.Cells(1, 1), source.Cells(1,
1).End(xlToRight))
For bytCounter = 1 To Int(source.Columns.Count / Spacing.Value)
strTemp = strTemp & " " & source.Cells(1, bytCounter *
Spacing.Value)
Next bytCounter
End If
EveryNth = Trim(strTemp)
End Function

where spacing is a cell with the value for 'Nth', and source would be the
range containing your source strings (it can be either the first column of
your source row, the entire source row, or even the entire source range)

hth.

Mike.
wrote in message
oups.com...
How do you copy every nth column of a row to the first cell of the row?


The values in the columns are string values and I'd like to place a
space between every value as it's inserted into the cell.

There are thousands of columns (using excel 2007) and each row is using
a different number of columns, so the macro will need to figure out
when the last column of data is in the row and stop at that point.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Match Column and copy to cell Column D Jeffrey Yau Excel Worksheet Functions 1 October 26th 09 12:53 AM
Copy last cell with data in column E on one sheet to cell on anoth Seahawk Excel Worksheet Functions 7 May 7th 09 02:52 AM
How do I copy every 8th cell in a column siverfox19482 Excel Discussion (Misc queries) 2 March 16th 05 05:47 PM
VBA to copy to empty cell directly below a cell when analogous cells in different column have same value as each other? Steven Rosenberg Excel Programming 0 August 5th 03 06:10 AM
VBA to copy to empty cell directly below a cell when analogous cells in different column have same value as each other? SROSENYC Excel Programming 1 August 5th 03 04:34 AM


All times are GMT +1. The time now is 06:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"