Ciao Elliot,
funziona alla perfezione. Mille grazie.
Prego! Mi fa piacere che tu abbia risolto il problema.
Giusto a titolo informativo/accademico:
Se creassi un template, con delle celle prestabilite sarebbe possibile possibile popolarle ad esempio dal foglio 1 al template (foglio 2) estrapolando da celle determinate a quelle del template anch'esse prestabilite?
Ad esempio, selezionando riga 1 del foglio 1 potrei estrapolare A1 C1 F1 e riceverle come output sul foglio 2 per esempio in posizioni H4 N7 e F3?
Certo! Basterebbe una leggera modifica della mia procedura.
Sono off topic?
No, per niente! A me risulta una domanda eminentemente legittima e un naturale seguito alla tua richiesta originale.
Quindi, per rendere la mia procedura più flessibile e più generica, prova qualcosa del genere:
- Alt+F11 per aprire l'editor di VBA
- Alt+IM per inserire un nuovo modulo di codice
- Nel nuovo modulo vuoto, incolla il seguente codice:
'=========>>
Option Explicit
'--------->>
Public Sub Tester2()
Dim newWB As Workbook
Dim srcSH As Worksheet
Dim destSH As Worksheet
Dim RngDati As Range, RngIn As Range
Dim destRng As Range, rCell As Range
Dim arrIn As Variant, arrOut() As Variant
Dim Res As Variant
Dim i As Long, j As Long, UB As Long
Const sColonneDaCopiare As String = "A:A,C:C,F:F,G:G,I:I"
Const sCelleDestinazione As String = "H4,N7,F3,K5,B2"
Set RngDati = ActiveCell.CurrentRegion
Set RngIn = Intersect(RngDati.Rows(ActiveCell.Row), _
ActiveSheet.Range(sColonneDaCopiare))
UB = RngIn.Cells.Count
ReDim arrIn(1 To UB)
For Each rCell In RngIn.Cells
i = i + 1
arrIn(i) = rCell.Value
Next rCell
Set newWB = Workbooks.Add(xlWBATWorksheet)
Set destSH = newWB.Sheets(1)
Set destRng = destSH.Range(sCelleDestinazione)
For Each rCell In destRng.Cells
j = j + 1
rCell.Value = arrIn(j)
Next rCell
Res = Application.GetSaveAsFilename(FileFilter:="File xlsx (*.xlsx, *.xlsx")
If Not Res = False Then
newWB.SaveAs Filename:=Res, FileFormat:=51
End If
End Sub
'<<=========
- Alt+Q per chiudere l'editor di VBA e tornare a Excel
- Salva il file con l’estensione xlsm
Potresti scaricare il mio file di prova Elliot#2_2011207.xlsm
===
Regards,
Norman
