나는 이것을 내 개인 일자리로 만들었습니다. Google에서 검색 한 후 여러 통합 문서 (각각 1 개의 워크 시트가 있음)를 하나의 통합 문서로 병합하는 코드를 발견했습니다. 그 워크 시트는 "shXetnaXe"를 부르는 이름이 같은, 그래서 난 통합 문서를 선택하려고 할 때, 그것은여러 통합 문서를 하나의 통합 문서로 병합 한 후 파일 이름을 기준으로 시트 이름 바꾸기
"shXetnaXe" for sheet(1)
"shXetnaXe(1)" for sheet(2)
"shXetnaXe(2)" for sheet(3)
결국 등등.
내가 그 시트가 자동으로 원래 선택한 통합 문서의 이름으로 명명 할 그 원래의 이름은 다음과 같습니다 "9월 1일" "9월 2일" "9월 3일" , 나는 그것을 시도를 조금 변경,하지만 항상 실패 .
여기에 문제가 openfiles.name이 파일의 전체 파일 경로와 이름을 반환되는 코드
`Sub opensheets()
Dim openfiles
Dim crntfile As Workbook
Set crntfile = Application.ActiveWorkbook
Dim x As Integer
On Error GoTo ErrHandler
Application.ScreenUpdating = False
openfiles = Application.GetOpenFilename _
(FileFilter:="Microsoft Excel Files (*.xls;*.xlsx),*.xls;*.xlsx", _
MultiSelect:=True, Title:="Select Excel file to merge!")
If TypeName(openfiles) = "Boolean" Then
MsgBox "You need to select atleast one file"
GoTo ExitHandler
End If
x = 1
While x <= UBound(openfiles)
Workbooks.Open Filename:=openfiles(x)
Sheets().Move After:=crntfile.Sheets(crntfile.Sheets.Count)
Set rnmsht = Workbook.Open
Sheets(openfiles) = rnmsht
Before:=ActiveWorkbook.Sheets(openfiles.name)
x = x + 1
Wend
Application.DisplayAlerts = False
Sheets(1).Select
ActiveWindow.SelectedSheets.Delete
ExitHandler:
Application.ScreenUpdating = True
Exit Sub
ErrHandler:
MsgBox Err.Description
Resume ExitHandler
End Sub'
어떤 라인에서 오류가 발생합니다? 아니면이 기능이 정상적으로 작동하며 추가 기능 만 사용하고 싶습니까? 원래 코드에 추가 한 행은 무엇입니까? –
여기 내 코드는 다음과 같습니다. Set rnmsht = Workbook.Open 시트 (openfiles) = rnmsht 이전 : = ActiveWorkbook.Sheets (openfiles.name) – tianda