View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default Macro to filter two columns

Sub bbb3()
FirstRow = 2 'Headings in row 1
LastRow = Range("B" & Rows.Count).End(xlUp).Row

For r = FirstRow To LastRow
If Cells(r, 1) < "" Then
TargetRow = r
addon = False
Else
addon = True
End If
LastCol = 6
myVal = ""
myVal = Cells(r, 2).Text
For i = 1 To 3
myVal = myVal & "-" & Cells(r, 2 + i).Text
Next i
Cells(TargetRow, LastCol).Value = _
Cells(TargetRow, LastCol).Value & IIf(addon, "; ", "") & myVal
Next r
Range("A1", Cells(TargetRow, 1)) _
.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End Sub


HTH,
Bernie
MS Excel MVP



"Polo78 Lacoste" wrote in message
...
Bernie,
Im trying to decifer the coding that you did, so I can try to understand
your coding and learn VBA more..

Basically, Im still having a problem with the if statement that you
place

If Cells(r, 1) = "" , the problem is, if the client has only one record,
it skips the row and does not place the contents on column B, C, D, on
the column F.

Also, I noticed the items are still not being placed on column F. I
cannot have more than 6 columns, total, regardless of how many items
there are for each client. Pls advise what is the vba function/formula
to concat and hold myVal to contain all previous items, so when the data
is ready to be copied, it will place all the data on column F.

Thank you again. BTW, your coding is awesome!



Thank you in advance.

Newbie to VBA.

*** Sent via Developersdex http://www.developersdex.com ***