Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
savvysam
 
Posts: n/a
Default VB Error, combining rows if...

I got a VB program from this board, and am trying to expand the ranges to
Columns A-G and combine contents of C if all other data in row matches that
of any other row, and if so then combine contents of column C in those rows
and delete extras. Tried to manually add in additional columns, as you'll
see below but keep getting object or application runtime error. Any
thoughts? Thanks!! I'll clarify if needed, Thx

Sub Concat()

Dim Iloop As Integer
Dim Numrows As Integer
Dim Counter As Integer

Application.ScreenUpdating = False

Numrows = Range("A65536").End(xlUp).Row
Range("A1:G" & Numrows).Select
Selection.Sort key1:=Range("A1"), Order1:=xlAscending, _
Key2:=Range("B1"), Order2:=xlAscending, Key3:=Range("C1"), _
Order3:=xlAscending, key4:=Range("D1"), Order4:=xlAscending, _
key5:=Range("E1"), Order5:=xlAscending, key6:=Range("F1"),
Order6:=xlAscending, _
key7:=Range("G1"), Order7:=xlAscending, Header:=xlYes, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom
For Iloop = Numrows To 2 Step -1
If Cells(Iloop, "A") & Cells(Iloop, "B") & Cells(Iloop, "D") &
Cells(Iloop, "E") & Cells(Iloop, "F") & Cells(Iloop, "G") _
= Cells(Iloop - 1, "A") & Cells(Iloop - 1, "B") & Cells(Iloop - 1, "D")
& Cells(Iloop - 1, "E") & Cells(Iloop - 1, "F") & Cells(Iloop - 1, "G") Then
Cells(Iloop - 1, "C") = Cells(Iloop - 1, "C") & ", " & Cells(Iloop, "C")
Rows(Iloop).Delete
End If
Next Iloop

Range("A1").Select

Application.ScreenUpdating = True

End Sub
  #2   Report Post  
TommySzalapski
 
Posts: n/a
Default


If Cells(Iloop, "A") & Cells(Iloop, "B") & Cells(Iloop, "D") &
Cells(Iloop, "E") & Cells(Iloop, "F") & Cells(Iloop, "G") _
= Cells(Iloop - 1, "A") & Cells(Iloop - 1, "B") & Cells(Iloop - 1,
"D")
& Cells(Iloop - 1, "E") & Cells(Iloop - 1, "F") & Cells(Iloop - 1, "G")
Then
Cells(Iloop - 1, "C") = Cells(Iloop - 1, "C") & ", " & Cells(Iloop,
"C")

should be

If Cells(Iloop, "A") = Cells(Iloop - 1, "A") & Cells(Iloop, "B") =
Cells(Iloop - 1, "B") etc. etc.

Szalapski


--
TommySzalapski
------------------------------------------------------------------------
TommySzalapski's Profile: http://www.excelforum.com/member.php...o&userid=25561
View this thread: http://www.excelforum.com/showthread...hreadid=398779

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
Insert rows based on specific value bob Excel Worksheet Functions 6 February 29th 08 07:11 PM
formula to use when number of rows changes dynamically confused Excel Worksheet Functions 3 August 17th 05 03:55 PM
REALLY miussing rows in Excel2000 Geoff Lambert Excel Discussion (Misc queries) 2 July 21st 05 03:20 PM
Hiding Rows if the linked rows are blank KG Excel Discussion (Misc queries) 9 May 18th 05 02:32 AM
Adding Rows to Master Sheet Excel Newbie New Users to Excel 1 December 23rd 04 10:56 PM


All times are GMT +1. The time now is 06:59 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"