Hello, I'm trying to copy, using code, a sheet to another workgroup.
I make this steps: Create a new file with name "file1.xlsx" and select the "totais" sheet from the "oldfile.xlsx" and when the code do the move command it gives an error : "run-time error 1004: Excel cannot insert the sheets into the destination workbook, because it contains fewer rows and columns than the source workgroup...".
They advise to copy only the cells that have data.
My source file has 1048576 rows by 'XFD' columns and the destination only has 65536rows by 'IV' columns.
i don't know why my source file has so many columns and rows. I don't need them...
Any help?
Code:
If NumTrab = 0 Then 'Se seleccionou TUDO então faz:
Workbooks.Add
ActiveWorkbook.SaveAs Filename:=TempFile, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
TempFile = ActiveWorkbook.Name
Windows(FicheiroActual).Activate
If Cb_5.Value = True Then 'TOTAIS ANO
Call TotaisAno
Sheets("TOTAIS").Move Before:=Workbooks(TempFile).Sheets(1)
End If
If Cb_2.Value = True Then 'Horas Trabalhadas
For x = 0 To UBound(ListaPessoal)
Nome = ListaPessoal(x, 1)
Call FazFolhaPessoal(Nome)
If FolhaInexistente = False Then
Workbooks(FicheiroActual).Sheets(ListaPessoal(x, 1)).Move After:=Workbooks(TempFile).Sheets(1)
End If
Next x
End If
If Cb_4.Value = True Then 'Horas de Acerto Mensais
Call Calcula_HA_Mensal
Workbooks(FicheiroActual).Sheets("Horas Acerto Mensal").Move Before:=Workbooks(TempFile).Sheets(1)
End If
If Cb_3.Value = True Then 'HCI's Mensais
Call Calcula_HCI_Mensal
Workbooks(FicheiroActual).Sheets("HCI Mensal").Move Before:=Workbooks(TempFile).Sheets(1)
End If
Workbooks(TempFile).Save 'Guarda Ficheiro
Workbooks(TempFile).Close
A = MsgBox("Dados gravados com sucesso no ficheiro " & TempFile, vbInformation + vbOKOnly)
Exit Sub
End If
Thank you,
Mário
Last edited by mjcordeiro; 06-04-2009 at 09:25 AM.
You need to post the code, remember to use Code Tags
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel Tips & Solutions, free examples and tutorials why not check out my downloads
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks