New sheet in external folder

chiabgigi

New Member
Joined
Aug 30, 2009
Messages
48
Ciao a tutti
con un pulsante voglio creare un nuovo foglio in un'altra cartella.
I valori contenuti in un foglio specifico della cartella di lavoro attiva verranno incollati in questo foglio.
Il nome del foglio è preso dalla cella A1 del foglio dove sono presenti i dati da copiare.
I dati da copiare partono dalla cella A1 fino all'ultima riga occupata.
Il problema è che mi dà l'errore 9, Indice fuori intervallo, nella riga 6.
Il file "listbox.xlsm" è attivo, mentre "data_gigi.xlsm" non lo è.
La macro "AddNewWorksheet" crea correttamente il nuovo foglio.

[CODE = vba]
Dim wb1 come cartella di lavoro
Dim wb2 come cartella di lavoro
Dim WS come foglio di lavoro
Dim LastRow As Long
Imposta wb1 = Cartelle di lavoro ("listbox.xlsm")
Imposta wb2 = Cartelle di lavoro ("data_gigi.xlsm") '<= here
Imposta ws = wb1.Worksheets ("Sheet4")

ws.Range ("A1") Selezionare
Selezione.Copia

wb2.Open
wb2.Worksheets ("Sheet1"). Attiva
Intervallo ("A1") Selezionare
ActiveSheet.Paste

Chiama AddNewWorksheet

wb1.Worksheets ("Sheet4"). Selezionare
Fogli ("Foglio4"). Celle (Rows.Count, 1) .End (xlUp) .Row.Select
Selezione.Copia

wb2.ActiveSheet.Select
LastRow = ActiveSheet.Cells (Rows.Count, 1) .End (xlUp) .Row
ActiveSheet.Paste
ActiveWorkbook.Save

Imposta wb2 = Nothing


End Sub [/ CODE]

è un errore nei percorsi?
quindi non credo sia corretto:
Fogli ("Foglio4"). Celle (Rows.Count, 1) .End (xlUp) .Row.Select
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
I humbly apologize to everyone for the mess made with the translator.
I repeat the question:
Hi everyone with a button I want to create a new sheet in another folder. Values contained in a specific sheet of the active workbook will be pasted into this sheet. The name of the sheet is taken from cell A1 of the sheet where the data to be copied is present. The data to be copied starts from cell A1 up to the last occupied row. The problem is that it gives me error 9, Index out of range, in line 6. The "listbox.xlsm" file is active, while "data_gigi.xlsm" is not. The "AddNewWorksheet" macro successfully creates the new sheet.

VBA Code:
Sub Macro4 ()
Dim wb1 as working directory
Dim wb2 as a working folder
Dim WS as a worksheet
Dim LastRow As Long
Set wb1 = Work Folders ("listbox.xlsm")
Set wb2 = Work Folders ("data_gigi.xlsm") '<= here
Set ws = wb1.Worksheets ("Sheet4")

ws.Range ("A1") Select
Selection.Copy

wb2.Open
wb2.Worksheets ("Sheet1"). Activate
Range ("A1") Select
ActiveSheet.Paste

Call AddNewWorksheet

wb1.Worksheets ("Sheet4"). To select
Sheets ("Sheet4"). Cells (Rows.Count, 1) .End (xlUp) .Row.Select
Selection.Copy

wb2.ActiveSheet.Select
LastRow = ActiveSheet.Cells (Rows.Count, 1) .End (xlUp) .Row
ActiveSheet.Paste
ActiveWorkbook.Save

Set wb2 = Nothing


End Sub

is it an error in the paths?
so i don't think it's correct:
Sheets ("Sheet4"). Cells (Rows.Count, 1) .End (xlUp) .Row.Select
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,206
Members
453,022
Latest member
RobertV1609

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top