Buonasera a tutti!
Sono nuovo del forum e mi rivoglo a voi per un piccolo aiuto sulle macro visto che sono anche un loro neofita
La situazione è questa ho un file con 2 fogli, in ognuno colonne di dati solo che nel secondo queste (le colonne) non sono ordinate come vorrei quindi la macro dovrebbe individuare nella prima riga del foglio 2 quale cella contiene il testo "x" copiare i dati della rispettiva colonna ed incollarli nel foglio uno nella cella C2 (ad esempio).
Ho provato a cercare qualcosa in rete ed adattarlo ma non sembra funzionare copio ed incollo comunqe:
Sub CopySignificant()
'Copy cells of cols A,F,E,D from rows containing "Significant" in
'col D of the active worksheet (source sheet) to cols
'A,B,C,D of Sheet2 (destination sheet)
Sheets("Sheet1").Select
Dim DestSheet As Worksheet
Set DestSheet = Worksheets("Sheet2")
Dim sRow As Long 'row index on source worksheet
Dim dRow As Long 'row index on destination worksheet
Dim sCount As Long
sCount = 0
dRow = 1
For sRow = 1 To Range("D65536").End(x1Up).Row
'use pattern matching to find "Significant" anywhere in cell
If Cells(sRow) Like "*BAR*" Then
sCount = sCount + 1
dRow = dRow
'copy cols A,F,E & D
Cells(sRow, "B").Copy Destination:=DestSheet.Cells(dRow, "A")
Cells(sRow + 2, "C").Copy Destination:=DestSheet.Cells(dRow, "B")
Cells(sRow + 3, "D").Copy Destination:=DestSheet.Cells(dRow, "C")
Cells(sRow + 4, "E").Copy Destination:=DestSheet.Cells(dRow, "D")
End If
Next sRow
MsgBox sCount & " Columns rows copied", vbInformation, "Transfer Done"
End Sub
Grazie in anticipo!