LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 536
Default Code to Concat a row in loop

Want to loop through A2:A10 and concat the first occupied cell to the last in each row into column A.

Code as is, if activecell is NOT in the A2:A10 range before running the code, code goes into endless loop. I am assuming that has to do with setting Lfcel and Rtcel using "Activecell.Row,".

If activecell is in A2:A10 then, then all cells are filled with the concat of that row only.

The "If i.Value 4 Then" is commented out while trying to get code to run correctly. Would like to be able to exclude certain values if the need arises. That could present major hassle as some of the values could be less than 4 and others could be regular text (A, b, Cx) etc. along with values greater than the 4 mentioned. (4 is arbitrary by the way, could be 6, whatever)

Thanks,
Howard

Option Explicit
Sub ConcatRow()

Dim c As Range
Dim i As Range
Dim Lfcel As Range
Dim Rtcel As Range

Set Lfcel = Cells(ActiveCell.Row, 2)
Set Rtcel = Cells(ActiveCell.Row, Columns.Count)

If IsEmpty(Lfcel) Then Set Lfcel = Lfcel.End(xlToRight)
If IsEmpty(Rtcel) Then Set Rtcel = Rtcel.End(xlToLeft)

For Each c In Range("A2:A10")
For Each i In Range(Lfcel, Rtcel)
'If i.Value 4 Then
c = c.Value & i.Value
'End If
Next ' i
Next 'c

End Sub
 
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
Concat rows - nmpb Excel Programming 13 January 17th 09 05:20 PM
concat rows nmpb Excel Worksheet Functions 4 January 15th 09 10:50 AM
Macro to concat row DavidH56 Excel Programming 10 June 5th 08 05:34 PM
howto: concat (x1:x3) Marc Hebert New Users to Excel 3 December 15th 06 07:52 PM
Excel code convert to Access code - Concat & eliminate duplicates italia Excel Programming 1 September 12th 06 12:14 AM


All times are GMT +1. The time now is 01:49 PM.

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

About Us

"It's about Microsoft Excel"