Thread: Automate Merge
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.newusers
John John is offline
external usenet poster
 
Posts: 2,069
Default Automate Merge

Max/Carlo,
Max the first formulae worked fine but no matter what I did I could not get
the second to work. I ended up changing it to: =IF(AND(C2<"";D2<"");D2&"
"&E2;E2). This seems to work but up to now I donĀ“t understand how. (I have
learnt a lot in the process though). I am still playing/fighting it. Carlo
thank you for the additional "clean up" code.

I hope others are benifiting from this exercise
John

"carlo" wrote:

Hi John

thanks for sending a more detailed explanation of your problem.
Max's solution looks good, although it doesn't delete your lines.

Following VBA Code should do what you need:
Sub CleanUp()

Dim SH As Worksheet
Dim Col As Integer

Set SH = Worksheets("Sheet1")
Col = 3

For i = SH.Cells(65536, Col).End(xlUp).Row To 2 Step -1
If SH.Cells(i, 1) = "" Then
SH.Cells(i - 1, Col).Value = _
SH.Cells(i - 1, Col).Value & SH.Cells(i, Col).Value
SH.Rows(i).Delete
End If
Next i

End Sub

You have to adjust SH and Col according to your sheet. I used column
one for checking if the line needs to be deleted, hope that is ok,
otherwise you need to change that as well.

I hope you understand what it does, otherwise just ask.

hth
Carlo