我有一个具有以下数据结构的Excel工作表
+-------------+-------------------------------+--+
| title | Dr. | |
| first_name | Adam | |
| last_name | Meyer | |
| email | adam.meyer@my-company.com | |
| phone | +49 (0)931-32187-0 | |
| fax | | |
| room | | |
| position | Direktor | |
| title | | |
| first_name | Judith | |
| last_name | Schmidt | |
| email | judith.schmidt@my-company.com | |
| phone | +49 (0)444-32131-1 | |
| fax | | |
| room | | |
| position | | |
| title | | |
| first_name | Claus | |
| last_name | Niemes | |
| email | claus.niemes@my-company.com | |
| phone | +49 (0)444-32131-2 | |
| fax | | |
| room | | |
| position | Verkäufer | |
| bio | xxxxxxxxxx | |
| title | Dr. | |
| first_name | András | |
| last_name | Cloon | |
| email | andrás.cloon@my-company.de | |
| phone | +49 (0)444-32131-1 | |
+-------------+-------------------------------+--+
并非所有450个人的所有行都有值。例如,有时会丢失标题的第一行。
我想将这些数据导入到mysql数据库中。
我不是excel专家,这就是为什么我对如何简化导入数据准备工作的每个提示感到满意的原因。
我知道如何导入。
答案 0 :(得分:1)
哦,我现在明白了你想要的东西
Sub SortItOUt()
Dim t As Range
Dim r As Range
Set t = Sheets(2).Range("a2") 'I assume a blank second sheet to collect the data
Set r = Sheets(1).Range("a1") 'assume data starts in sheet 1
Do
Dim x As Long
For x = 0 To 7
r.Offset(x, 1).Copy t.Offset(0, x) 'copy and transpose
Next x
Set t = t.Offset(1, 0)
Set r = r.Offset(8, 0)
Loop Until r = ""
End Sub