View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Patrick Molloy[_2_] Patrick Molloy[_2_] is offline
external usenet poster
 
Posts: 1,298
Default I need help writing a macro to replace cell contents. (new to

I suggest
1) collect all the unique ID's
2) build your new table

1)
We're going to use a collection, more specifically a dictionary object, to
use the .Exists method to test if keys exist.
In the IDE, set a refence to Microsoft Scripting Runtime
in a module, paste
Option Explicit
Private dGUIDs As Scripting.Dictionary
Sub GetIDs()
Dim wsheets() As Variant
Dim ws As Worksheet
Dim wsIndex As Long
Dim cell As Range
Dim key As String
wsheets = Array("sheet1", "sheet2")
Set dGUIDs = New Scripting.Dictionary

For wsIndex = 0 To UBound(wsheets, 1)
Set ws = Worksheets(wsheets(wsIndex))
With ws
For Each cell In .Range(.Range("A1"), .Range("A1").End(xlDown))

key = cell.Value
If key < "" Then
If Not dGUIDs.Exists(key) Then
dGUIDs.Add key, key
End If
End If

Next
Next
End Sub

2) ? you haven't specified how records on more than one sheet get merged. I
assume in (1) that column A had the GUIDs. Apart from A then, do the columns
dffer on other woksheets?
This step should output the ID's into A on a new sheet, then for each of
your worksheets copy rows to the relevent columns of the output sheet. so
sheet1 may be columns B- G, sheet2 columns H-M and so on?
does this sound right....I 'll spend the time writing the code when this is
clearer.



"Patrick Molloy" wrote:

if you use MS Access, this becomes trivial. open a new Access database, link
a table to each of the sheets, open a query, add all the sheets & seelct
everything, using the GUID as the key for all sheets. The resultant results
can be resaved as a table and then you can suck it straight into your main
database.



"Emoshag" wrote:

Hello,

I am building an Oracle database and I am going to be using Excel to injest
the data. I am trying to give unique values to records and to do so I have
been hand copying rows between different worksheets and pasting the same GUID
(unique identifier) on matching column values between different worksheets.

I am desparately trying to find a time saving function or macro because this
task is taking way too long now that I am getting +50,000 records.

Is there a way to create a unique ID for a cell and then copy and paste
that ID into a cell in a specific row on another worksheet where a cell in
the target row is identical to a cell from the row where the ID is being
copied from?

I am desparate at this point, so if anyone has any ideas or needs more
information, I would be more thatn happy to provide it.