Grazie ap, l'avevo pensato anch'io in seguito e l'avevo già risolto in questo modo.
il problema successivo e che adesso il fogli oexcel ha un bel pò di roba proveniente da più fonti ed ho bisogno di riordinare in base a dei valori di una colonna.
ho anche implementato l'algoritmo di riordini con un ciclo do until, e funziona tutto, almeno alla prima attivazione. nelle successivr mi restituisce sempre un errore metodo cells dell'oggetto global non riuscito. Mi spiego, il trasferimento e il riordino viene fatto bene solo alla prima interrogazione, nelle successive si pianta.
ecco il codice
codice:
With ExWs
Do Until (n = h + 1)
  .Cells(h + 1, 1).Value = .Cells(n, 1).Value
  .Cells(h + 1, 2).Value = .Cells(n, 2).Value
  .Cells(h + 1, 3).Value = .Cells(n, 3).Value
  .Cells(h + 1, 4).Value = .Cells(n, 4).Value
  Do Until (z = h + 1)
  If .Cells(z, 1).Value < .Cells(h + 1, 1) Then
    .Cells(h + 2, 1).Value = .Cells(h + 1, 1).Value ' alla prima query risponde bene...
    .Cells(h + 2, 2).Value = .Cells(h + 1, 2).Value ' ...ma alla seconda come al solito
    .Cells(h + 2, 3).Value = .Cells(h + 1, 3).Value
    .Cells(h + 2, 4).Value = .Cells(h + 1, 4).Value
    .Cells(h + 1, 1).Value = Cells(z, 1).Value ' e qui mi dà l'errore metodo cells global
    .Cells(h + 1, 2).Value = Cells(z, 2).Value
    .Cells(h + 1, 3).Value = Cells(z, 3).Value
    .Cells(h + 1, 4).Value = Cells(z, 4).Value
    .Cells(n, 1).Value = .Cells(h + 1, 1).Value
    .Cells(n, 2).Value = .Cells(h + 1, 2).Value
    .Cells(n, 3).Value = .Cells(h + 1, 3).Value
    .Cells(n, 4).Value = .Cells(h + 1, 4).Value
    .Cells(z, 1).Value = .Cells(h + 2, 1).Value
    .Cells(z, 2).Value = .Cells(h + 2, 2).Value
    .Cells(z, 3).Value = .Cells(h + 2, 3).Value
    .Cells(z, 4).Value = .Cells(h + 2, 4).Value
  End If
  z = z + 1
  Loop
z = n + 1
n = n + 1
Loop
.Cells(h + 1, 1).Value = ""
.Cells(h + 1, 2).Value = ""
.Cells(h + 1, 3).Value = ""
.Cells(h + 1, 4).Value = ""
.Cells(h + 2, 1).Value = ""
.Cells(h + 2, 2).Value = ""
.Cells(h + 2, 3).Value = ""
.Cells(h + 2, 4).Value = ""
End With ' fine riordino