can anyone assist with an excel access normalisation problem

990405

Board Regular
Joined
Jun 29, 2004
Messages
53
Could you kindly assist with following.
I presently have records stored in Excel and would like to know how I could transfer these records into Access and also normalise into tables and also remove duplicates.

given below typical Excel records


Company name, tel, fax, SIC sector
A company may operate in several sectors, i.e clothing

ACME, tel, fax, clothing womens
ACME, tel, fax, clothing mens
ACME, tel, fax, clothing childrens
ACME, tel, fax, clothing sporting
ACME, tel, fax, clothing hosiery

I would like to get to

ACME, tel, fax, clothing womens
clothing mens
clothing childrens
clothing sporting
clothing hosiery

the company name (same tel & fax) in a record at times is duplicated, but what differs is the sector.
I would like to retain the company name (once), but not remove the differing sectors it operates in.

I have mangaged to remove duplicates, but the solution is partial and inadequate, since it keeps the first record it meets, but removes subsequent sectors.
i.e.
ACME, tel, fax, clothing womens


any assistance?

thanking you in advance
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Re: can anyone assist with an excel access normalisation pro

Welcome to the Board!

You can concatenate to create a unique field. You can then peform a de-dupe query in Access to get what you need. Or we can post some code to delete duplicates.
Book3
ABCDE
1ACMEtelfaxclothingwomensACMEclothingwomens
2ACMEtelfaxclothingmensACMEclothingmens
3ACMEtelfaxclothingchildrensACMEclothingchildrens
4ACMEtelfaxclothingsportingACMEclothingsporting
5ACMEtelfaxclothinghosieryACMEclothinghosiery
Sheet1


Hope that helps,

Smitty
 
Upvote 0
Re: can anyone assist with an excel access normalisation pro

Is clothing the only qualifier regarding the SIC Sectors?
 
Upvote 0
Re: can anyone assist with an excel access normalisation pro

could you send some code to remove duplicates and what is procedure for de-dupes in access?

thanks fo your assistance
 
Upvote 0
Re: can anyone assist with an excel access normalisation pro

Aladin Akyurek said:
Is clothing the only qualifier regarding the SIC Sectors?

sic is a field, the sic code can be many different sectors from food to industrial compnents or services
 
Upvote 0
Re: can anyone assist with an excel access normalisation pro

Here's the delete code for Excel:

<font face=Tahoma><SPAN style="color:#00007F">Sub</SPAN> Column_Sort_DeleteDuplicates_()
    <SPAN style="color:#007F00">'   Code by Ponsy Nob.</SPAN>
    <SPAN style="color:#00007F">Dim</SPAN> col%, c%, x%, rng <SPAN style="color:#00007F">As</SPAN> Range
    col = 1  <SPAN style="color:#007F00">'1 is the column number to search - change it as required</SPAN>
    <SPAN style="color:#007F00">'   I.E. Column A = 1, Column B = 2, etc</SPAN>
    
    <SPAN style="color:#007F00">'   Set the column number of the column to store temporary formula</SPAN>
    c = Range([A1], ActiveSheet.UsedRange).Columns.Count + 1
    <SPAN style="color:#007F00">'   Exit if the used columns=256 (instead of exiting, could amend the code _
    to look for a column containing no data to use for the temporary formula)</SPAN>
    <SPAN style="color:#00007F">If</SPAN> c > 256 <SPAN style="color:#00007F">Then</SPAN> <SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
    <SPAN style="color:#007F00">'   Set the column offset(from the search column to the temp. formula column)</SPAN>
    x = col - c
    
    <SPAN style="color:#007F00">'   Turn off screen-updating and set calculation to manual _
    (if required, could add a test to check if calculation is already set _
    to manual, in which case would not want to set to automatic at the end</SPAN>
    <SPAN style="color:#00007F">With</SPAN> Application
        .ScreenUpdating = <SPAN style="color:#00007F">False</SPAN>
        .Calculation = xlCalculationManual
    <SPAN style="color:#007F00">'   Set the range to contain the temp. formula</SPAN>
        <SPAN style="color:#00007F">Set</SPAN> rng = Range(Cells(1, c), Cells(65536, col).End(xlUp).Offset(, -x))
        <SPAN style="color:#00007F">With</SPAN> rng
    <SPAN style="color:#007F00">'   Sort the data by the search column</SPAN>
            .EntireRow.Sort Key1:=rng(1, x + 1), Order1:=xlAscending, Header:=xlNo
    <SPAN style="color:#007F00">'   Put temp. value in the fors cell of the temp.column</SPAN>
            rng(1) = 1
    <SPAN style="color:#007F00">'   Enter the temp formula that identifies duplicates</SPAN>
            .Offset(1).FormulaR1C1 = "=IF(RC[" & x & "]=R[-1]C[" & x & "],"""",1)"
    <SPAN style="color:#007F00">'   Convert the formula to value</SPAN>
            .Offset(1) = .Offset(1).Value
    <SPAN style="color:#007F00">'   Sort entire rows by the temp. formula result so as to group all of _
        the rows to be deleted at the end</SPAN>
            .EntireRow.Sort Key1:=rng(1), Order1:=xlAscending, Header:=xlNo
    <SPAN style="color:#007F00">'   Error handler in case there are no duplicates</SPAN>
           <SPAN style="color:#00007F">On</SPAN> <SPAN style="color:#00007F">Error</SPAN> <SPAN style="color:#00007F">Resume</SPAN> <SPAN style="color:#00007F">Next</SPAN>
    <SPAN style="color:#007F00">'   Delete the duplicate rows</SPAN>
            .SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    <SPAN style="color:#007F00">'   Reset error handling</SPAN>
            <SPAN style="color:#00007F">On</SPAN> <SPAN style="color:#00007F">Error</SPAN> <SPAN style="color:#00007F">GoTo</SPAN> 0
        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN>
    <SPAN style="color:#007F00">'   Delete the temp. formula column</SPAN>
        Columns(c).Delete
    <SPAN style="color:#007F00">'   Reset the sheet's last used cell</SPAN>
        ActiveSheet.UsedRange
    <SPAN style="color:#007F00">'   Turn on screen-updating and set calculation to automatic</SPAN>
        .ScreenUpdating = <SPAN style="color:#00007F">False</SPAN>
        .Calculation = xlCalculationManual
    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN>

<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
</FONT>

For Access, check the helpfile. It documents the procedure very well.

Smitty
 
Upvote 0
Re: can anyone assist with an excel access normalisation pro

990405 said:
Aladin Akyurek said:
Is clothing the only qualifier regarding the SIC Sectors?

sic is a field, the sic code can be many different sectors from food to industrial compnents or services

I'm not sure this answers my question... It seems to me that you should first normalize & the following tables might be sufficient to cover the sample data you provided:

COMPANIES(Company#,Cname,Ctel,Cfax)

SIC-SECTORS(Sector#,Description)

COMPANY-SECTOR DETAILS(Company#,Sector#)

A record from COMPANIES would be:

ACME,ACME International,978-9876971,978-98766972

A record from SIC-SECTORS...

S0001,Clothing Mens

A record from the last table...

ACME,S0001

If you create 3 worksheets carrying table names as sheet names, you can import these sheets easily into Access, then fix the data types for each field, and set the relationships between them.
 
Upvote 0
Re: can anyone assist with an excel access normalisation pro

pennysaver said:
Welcome to the Board!

You can concatenate to create a unique field. You can then peform a de-dupe query in Access to get what you need. Or we can post some code to delete duplicates.
Book3
ABCDE
1ACMEtelfaxclothingwomensACMEclothingwomens
2ACMEtelfaxclothingmensACMEclothingmens
3ACMEtelfaxclothingchildrensACMEclothingchildrens
4ACMEtelfaxclothingsportingACMEclothingsporting
5ACMEtelfaxclothinghosieryACMEclothinghosiery
Sheet1


Hope that helps,

Smitty
********************
Procedure?
could you send some code to remove duplicates for Access (query) and what is procedure for "de-dupes" in access?

Is this a normalisation problem and as such can this be resolved via better normalisation?

thanks
thanks fo your assistance
 
Upvote 0
Re: can anyone assist with an excel access normalisation pro

Here is some code for deleting duplicates in Excel:

<font face=Tahoma><SPAN style="color:#00007F">Sub</SPAN> Column_Sort_DeleteDuplicates_()
    <SPAN style="color:#007F00">'   Code by Ponsy Nob.</SPAN>
    <SPAN style="color:#00007F">Dim</SPAN> col%, c%, x%, rng <SPAN style="color:#00007F">As</SPAN> Range
    col = 1  <SPAN style="color:#007F00">'1 is the column number to search - change it as required</SPAN>
    <SPAN style="color:#007F00">'   I.E. Column A = 1, Column B = 2, etc</SPAN>
    
    <SPAN style="color:#007F00">'   Set the column number of the column to store temporary formula</SPAN>
    c = Range([A1], ActiveSheet.UsedRange).Columns.Count + 1
    <SPAN style="color:#007F00">'   Exit if the used columns=256 (instead of exiting, could amend the code _
    to look for a column containing no data to use for the temporary formula)</SPAN>
    <SPAN style="color:#00007F">If</SPAN> c > 256 <SPAN style="color:#00007F">Then</SPAN> <SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
    <SPAN style="color:#007F00">'   Set the column offset(from the search column to the temp. formula column)</SPAN>
    x = col - c
    
    <SPAN style="color:#007F00">'   Turn off screen-updating and set calculation to manual _
    (if required, could add a test to check if calculation is already set _
    to manual, in which case would not want to set to automatic at the end</SPAN>
    <SPAN style="color:#00007F">With</SPAN> Application
        .ScreenUpdating = <SPAN style="color:#00007F">False</SPAN>
        .Calculation = xlCalculationManual
    <SPAN style="color:#007F00">'   Set the range to contain the temp. formula</SPAN>
        <SPAN style="color:#00007F">Set</SPAN> rng = Range(Cells(1, c), Cells(65536, col).End(xlUp).Offset(, -x))
        <SPAN style="color:#00007F">With</SPAN> rng
    <SPAN style="color:#007F00">'   Sort the data by the search column</SPAN>
            .EntireRow.Sort Key1:=rng(1, x + 1), Order1:=xlAscending, Header:=xlNo
    <SPAN style="color:#007F00">'   Put temp. value in the fors cell of the temp.column</SPAN>
            rng(1) = 1
    <SPAN style="color:#007F00">'   Enter the temp formula that identifies duplicates</SPAN>
            .Offset(1).FormulaR1C1 = "=IF(RC[" & x & "]=R[-1]C[" & x & "],"""",1)"
    <SPAN style="color:#007F00">'   Convert the formula to value</SPAN>
            .Offset(1) = .Offset(1).Value
    <SPAN style="color:#007F00">'   Sort entire rows by the temp. formula result so as to group all of _
        the rows to be deleted at the end</SPAN>
            .EntireRow.Sort Key1:=rng(1), Order1:=xlAscending, Header:=xlNo
    <SPAN style="color:#007F00">'   Error handler in case there are no duplicates</SPAN>
           <SPAN style="color:#00007F">On</SPAN> <SPAN style="color:#00007F">Error</SPAN> <SPAN style="color:#00007F">Resume</SPAN> <SPAN style="color:#00007F">Next</SPAN>
    <SPAN style="color:#007F00">'   Delete the duplicate rows</SPAN>
            .SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    <SPAN style="color:#007F00">'   Reset error handling</SPAN>
            <SPAN style="color:#00007F">On</SPAN> <SPAN style="color:#00007F">Error</SPAN> <SPAN style="color:#00007F">GoTo</SPAN> 0
        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN>
    <SPAN style="color:#007F00">'   Delete the temp. formula column</SPAN>
        Columns(c).Delete
    <SPAN style="color:#007F00">'   Reset the sheet's last used cell</SPAN>
        ActiveSheet.UsedRange
    <SPAN style="color:#007F00">'   Turn on screen-updating and set calculation to automatic</SPAN>
        .ScreenUpdating = <SPAN style="color:#00007F">False</SPAN>
        .Calculation = xlCalculationManual
    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN>

<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
</FONT>

As for how to do it in Access, look in the helpfile for delete duplicates. It's very well documented.

Smitty
 
Upvote 0

Forum statistics

Threads
1,221,783
Messages
6,161,938
Members
451,730
Latest member
BudgetGirl

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top