LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default Merging wordsheets in Excel 2007

Hi Ivanov,

Very good to hear and thanks for the feedback. Us Ivan's have to stick
together :)

Cheers,

On Apr 2, 1:47*am, "
wrote:
Hi Ivyleaf,

Now the macro works like charm! Thank you very much for your help.

You rule!

And here is the final macro for someone else who may need it:

Sub MergeList()
* * Dim FrList As Range, DeList As Range, DestList As Range
* * Dim cell As Range, WordList As New Collection, i As Integer

'This sets the range of the French list
* * Set FrList = Sheets("French").Range("A1")
* * Set FrList = Range(FrList, FrList.Range("A65536").End(xlUp))
* * FrList.Resize(FrList.Rows.Count, 2).Name = "FrList"

'This sets the range of the German list
* * Set DeList = Sheets("German").Range("A1")
* * Set DeList = Range(DeList, DeList.Range("A65536").End(xlUp))
* * DeList.Resize(DeList.Rows.Count, 2).Name = "DeList"

'This sets the range of the new destination list
* * Set DestList = Sheets("Merged").Range("A1")

'Turn off screen refresh & calculation to speed up execution
* * Application.ScreenUpdating = False
* * Application.Calculation = xlCalculationManual

'Error handling for when the program attempts to add
'the same word to the collection twice
* * On Error Resume Next

'Add English words from French list
* * * * For Each cell In FrList.Cells
* * * * * * If Not IsEmpty(cell) Then
* * * * * * WordList.Add cell.Value, CStr(cell.Value)
* * * * * * End If
* * * * Next

'Add English words from German list (ignoring duplicates)
* * * * For Each cell In DeList.Cells
* * * * * * If Not IsEmpty(cell) Then
* * * * * * WordList.Add cell.Value, CStr(cell.Value)
* * * * * * End If
* * * * Next

'Turn error notification back on
* * On Error GoTo 0

'Resize destination list to fit total words
* * Set DestList = DestList.Resize(WordList.Count, 1)

'Loop to put words to new list
* * i = 1
* * For Each Item In WordList
* * * * DestList.Cells(i) = Item
* * * * i = i + 1
* * Next

'Sort new list alphabetically
* * DestList.Sort DestList, xlAscending

'Perform code based VLookup for French and German
* * On Error Resume Next
* * For Each cell In DestList.Cells
* * * * FrList.Cells(Application.Match(cell.Value, FrList,
0)).Offset(0, 1).Copy
* * * * If Err.Number = 0 Then Sheets("Merged").Paste
Destination:=cell.Offset(0, 1)
* * * * Err.Clear
* * * * DeList.Cells(Application.Match(cell.Value, DeList,
0)).Offset(0, 1).Copy
* * * * If Err.Number = 0 Then Sheets("Merged").Paste
Destination:=cell.Offset(0, 2)
* * * * Err.Clear
* * Next

'Clean up
* * With Sheets("Merged")
* * * * .Rows("1:1").Insert Shift:=xlDown
* * * * .Range("A1:C1") = Array("English", "French", "German")
* * * * .Columns.AutoFit
* * * * .Rows.AutoFit
* * * * .Cells.VerticalAlignment = xlTop
* * End With
* * Application.ScreenUpdating = True
* * Application.Calculation = xlCalculationAutomatic

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
Help merging excel sheets (2007) on a common field campanellisj Excel Worksheet Functions 1 December 8th 10 07:33 PM
rearrangimg data in excel2007 for merging into word 2007 Andrew atkent Excel Discussion (Misc queries) 0 April 25th 10 05:19 PM
Merging identical workbooks in Excel 2007 deegee Excel Discussion (Misc queries) 0 November 20th 08 01:55 PM
Excel 2007 - Why is Cell Merging Disabled? Michael Excel Discussion (Misc queries) 5 April 25th 08 05:22 PM
Merging workbooks in 2007 scoz Excel Discussion (Misc queries) 0 October 10th 07 02:51 PM


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