PDA

View Full Version : Choose from several sheets



marreco
08-27-2012, 12:46 AM
Hi.

I'm with the problem in a file that I have, I'll try to explain the best way.
When I chose the name of the worksheet as follows: "Set Original = Workbooks (Source). Worksheets (" Sheet1 ") 'my code worked, now that he tried to fetch the name to a sheet covering a column.
It gets its name there but when does "Set Original = Workbooks (Source). Worksheets (name)" says subscript out of range error 9.

Dim Destino As String
Dim Origem As String
Dim Original As Worksheet
Dim Copia As Worksheet
Dim Folha As Worksheet
Dim nome As String

linha = 53

For lin = 1 To linha

Set Folha = Workbooks(Destino).Worksheets("Instalacoes")

nome = Folha.Cells(lin, 1).Value

Workbooks.Open Filename
Origem = ActiveWorkbook.Name

Set Original = Workbooks(Origem).Worksheets(nome)

Set Copia = Workbooks(Destino).Worksheets(nome)
Thanks in advance!

Admin
08-27-2012, 12:07 PM
Hi marreco,

Welcome t oExcelFox !!

It means there is no such sheet what the variable 'nome' returns. Check your sheet name.

marreco
08-27-2012, 04:39 PM
Hi
Thanks, the problem was solved by your tip, thank you very much!

swinnersmusic
08-29-2012, 02:46 AM
there is no NEXT following the FOR loop.
What is this code trying to achieve please?