나는 긴 이름 목록과 이름과 관련된 고유 한 값을 가진 데이터베이스를 가지고있다. 내가하고 싶은 일은 각 개인에 대해 하나의 워크 시트를 만든 다음 워크 시트의 지정된 범위로 데이터를 복사 한 후 다음 개인으로 진행하여 데이터를 워크 시트 등에 복사하는 것입니다.엑셀 데이터베이스에서 데이터 추출
Here은 링크입니다. 예제 워크 시트 (Google 워드 프로세서 양식, 메모 - 실제로 Google 워드 프로세서가 아닌 Excel 2010을 사용 중입니다).
"Employee"라는 새 시트에 다음 코드를 사용하여 모든 워크 시트를 만들 수있었습니다. 내가이 시트에 한 것은 워크 시트의 모든 이름 목록을 가질 수 있도록 중복 된 이름 값을 제거하는 것이 었습니다.
도움을 주시면 감사하겠습니다. 미리 감사드립니다.
Sub CreateSheetsFromAList()
Dim nameSource As String 'sheet name where to read names
Dim nameColumn As String 'column where the names are located
Dim nameStartRow As Long 'row from where name starts
Dim nameEndRow As Long 'row where name ends
Dim employeeName As String 'employee name
Dim newSheet As Worksheet
nameSource = "Employee"
nameColumn = "A"
nameStartRow = 1
'find the last cell in use
nameEndRow = Sheets(nameSource).Cells(Rows.Count, nameColumn).End(xlUp).Row
'loop till last row
Do While (nameStartRow <= nameEndRow)
'get the name
employeeName = Sheets(nameSource).Cells(nameStartRow, nameColumn)
'remove any white space
employeeName = Trim(employeeName)
' if name is not equal to ""
If (employeeName <> vbNullString) Then
On Error Resume Next 'do not throw error
Err.Clear 'clear any existing error
'if sheet name is not present this will cause error that we are going to leverage
Sheets(employeeName).Name = employeeName
If (Err.Number > 0) Then
'sheet was not there, so it create error, so we can create this sheet
Err.Clear
On Error GoTo -1 'disable exception so to reuse in loop
'add new sheet
Set newSheet = Sheets.Add(After:=Sheets(Sheets.Count))
'rename sheet
newSheet.Name = employeeName
'paste training material
Sheets(employeeName).Cells(1, "A").PasteSpecial
Application.CutCopyMode = False
End If
End If
nameStartRow = nameStartRow + 1 'increment row
Loop
End Sub
그래서 정확히 무엇이 문제입니까? –
실제 문서에는 약 200 가지 이상의 개별 이름이 있으며 각 고유 이름에 대해 약 200 줄 정도의 데이터가 있습니다. 하나의 이름에 대해 모든 데이터 포인트를 자동으로 선택하고 해당 이름에 해당하는 워크 시트에 붙여 넣은 다음 목록의 다음 고유 이름으로 이동하는 방법을 찾고 있습니다. 이 작업을 수동으로 수행하면 (이름에 대한 필터 사용) 매우 오랜 시간이 걸리며 오류가 발생하기 쉽습니다. – user2829172