D
D
Darkzenon2018-01-21 17:53:26
Visual Basic
Darkzenon, 2018-01-21 17:53:26

How to structure an excel table?

Good afternoon.
there is a table obtained from the forms of employees (1000 pcs.)
employees go line by line. the problem is that in each employee form, the order of the columns and their number is different.
and the second problem is that there are several identical fields. type "check date."
also there is a cant that there are typos in the names of the form fields. certificate, certificate certificate certificate certificate.
Schematically, the data looks like this.
A B C
A B C
B A A
A B C D Y
D E A A
The goal is to make a table and place the same fields of the employee table in one column. For columns of unique content like "Name" this is not a problem, the cant appears when I post data on columns of which there can be a lot. there is only one column and only one data in it.
Does anyone have ideas on how to solve the problem,
to search for and space apart unique columns, I made such a code in vba.
The data itself is in csv, but that won't help much.

spoiler
Dim dicTemp1 As Dictionary
Set dicTemp1 = CreateObject("Scripting.Dictionary")

Dim headDic As Dictionary
Set headDic = CreateObject("Scripting.Dictionary")
  
newrow = 2

For i = 2 To 60 Step 2
    dicTemp1.RemoveAll
    
    For x = 4 To 79
            
            If dicTemp1.Exists(Cells(i, x).value) Then ' если значение есть в списке заголовков СТРОКИ
                dicTemp1.Item(Cells(i, x).value) = dicTemp1.Item(Cells(i, x).value) + 1
                DoubleFlag = 1
            Else
                dicTemp1.Add Cells(i, x).value, 1
                DoubleFlag = 0
            End If

            If DoubleFlag = 0 Then
                If headDic.Exists(Cells(i, x).value) Then ' если значение есть в списке заголовков ТАБЛИЦЫ
                    Worksheets("Лист2").Cells(newrow, headDic.Item(Cells(i, x).value)) = Cells(i + 1, x).value
                Else
                    headDic.Add Cells(i, x).value, headDic.Count + 1
                    Worksheets("Лист2").Cells(1, headDic.Count) = Cells(i, x).value
                    Worksheets("Лист2").Cells(newrow, headDic.Count) = Cells(i + 1, x).value
                End If
            Else
                    lastCol = Worksheets("Лист2").Cells(1, Worksheets("Лист2").Columns.Count).End(xlToLeft).Column
                    Worksheets("Лист2").Cells(1, lastCol) = Cells(i, x).value
                    Worksheets("Лист2").Cells(newrow, lastCol) = Cells(i + 1, x).value
               End If
    Next
    newrow = newrow + 1
Next

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
res2001, 2018-01-22
@res2001

In fact, this is a semi-manual work.
It is necessary to bring all the tables to a single form, and then load them.
Or make a script to download 1 file, which we managed to transfer with a script, the rest by hand.
It was necessary to think before handing out the form to fill out.
As an option - to prepare a universal form and, having included an administrative resource, lower it with the requirement to bring everything to a common view. It is better to protect the form with a password, leaving only the necessary cells for editing, where you can add a choice from the possible options and other input validation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question