Autres Propriété Resize

Calvus

XLDnaute Barbatruc
Bonjour le forum,

Est il possible de ne sélectionner que certaines colonnes avec la propriété Resize ?

Par exemple le tableau (a) va de A1 à J50 et on voudrait ne ré-écrire que les colonnes A C et F
Ce qui donnerait (dans l'idée) : Range("A1").Resize(i, 1 & 2 & 3) = a
Ce qui ne fonctionne pas évidemment.

Merci
 

Calvus

XLDnaute Barbatruc
Bonjour Job75, danielco,

Merci de vos réponses.
Bon, cette propriété va m'être utile pour la suite.
En revanche elle me met le bazar dans mon cas, à moins que je n'ai mal adapté.

Voici le code utilisé :
VB:
    ''Inscription colonne sorties après sorties du bl
    t0 = f.Range("A20" & ":H53")                                       't   Tableau en BL                 (t  3) = ref, (t  5) = quantité BL
ReDim a(1 To UBound(t0), 8)
Dim n
    For i = 1 To UBound(a) - 1
        For j = 3 To UBound(t1)
            'Si entrées moins sorties < qté demandée alors x en col A
            If t1(j, 5) - t1(j, 6) < t0(i, 5) And t1(j, 1) = t0(i, 3) And t0(i, 3) <> "" Then
                a(i, 0) = "x"
                a(i, 2) = t0(i, 3)
                a(i, 3) = t0(i, 4)
                a(i, 4) = t1(j, 5) - t1(j, 6)
            End If
        Next j
    Next i

Intersect([V145:Z179], [V:V,Y:Y,Z:Z]) = a

J'ai rusé en créant d'autres tableaux pour extraire mes valeurs, je vous mets le code qui fonctionne et qui peut suffire de toute façon, même si j'aurais préféré quelque chose de plus court.
Code:
    ''Inscription colonne sorties après sorties du bl
    t0 = f.Range("A20" & ":H53")                                       't   Tableau en BL                 (t  3) = ref, (t  5) = quantité BL
ReDim a(1 To UBound(t0), 8)
Dim n
    For i = 1 To UBound(a) - 1
        For j = 3 To UBound(t1)
            'Si entrées moins sorties < qté demandée alors x en col A
            If t1(j, 5) - t1(j, 6) < t0(i, 5) And t1(j, 1) = t0(i, 3) And t0(i, 3) <> "" Then
                a(i, 0) = "x"
                a(i, 2) = t0(i, 3)
                a(i, 3) = t0(i, 4)
                a(i, 4) = t1(j, 5) - t1(j, 6)
'            End If
        Next j
    Next i

Dim a0(), a1(), a2()
ReDim a0(1 To UBound(a), 1)
ReDim a1(1 To UBound(a), 1)
ReDim a2(1 To UBound(a), 1)

    For i = 1 To UBound(a) - 1
    a0(i, 0) = a(i, 0)
    Next i
    
    For i = 1 To UBound(a) - 1
    a1(i, 0) = a(i, 4)
    Next i
   f2.Range("V145").Resize(i, 1) = a0
   f2.Range("Z145").Resize(i, 1) = a1
'        Erase a

Je peux vous fournir un exemple si vous voulez plus de détails, mais ne vous embêtez pas sinon, car j'ai (presque) ce que je souhaite.

Merci et bonne journée
 

danielco

XLDnaute Accro
Peut-être :

VB:
  Set f = Sheets("feuil1")
  t0 = f.Range("A20" & ":H53")                                      't   Tableau en BL                 (t  3) = ref, (t  5) = quantité BL
  ReDim a(1 To UBound(t0), 8)
  ReDim a1(1 To UBound(t0))
  ReDim a2(1 To UBound(t0))
  Dim n
  For i = 1 To UBound(a) - 1
      For j = 3 To UBound(t1)
          'Si entrées moins sorties < qté demandée alors x en col A
          If t1(j, 5) - t1(j, 6) < t0(i, 5) And t1(j, 1) = t0(i, 3) And t0(i, 3) <> "" Then
              a1(i) = t0(i, 3)
              a2(i) = t0(i, 4)
          End If
      Next j
  Next i
[V145:V179] = "x"
[Y145:Y179] = a1
[Z145:Z179] = a2

Daniel
 

patricktoulon

XLDnaute Barbatruc
bonjour
@danielco
VB:
 For i = 1 To UBound(a) - 1
      For j = 3 To[B][SIZE=6] UBound(t1)[/SIZE][/B]


pouvez vous me dire dans votre code où la variable tableau t1 est instancié ??????????????

et quand on redim une variable tableau
exemple a et a1 redimer par raport à a
soit on redim de meme dimention
soit l'ors de la transpostion on transpose car a1 et a2 sont des tableaux (UNE DIMENTION )

sauf t1 qui est inconnu dans ce code
Code:
Sub test()
Dim t0, a1, a2, a
Set f = Sheets("feuil1")
  t0 = f.Range("A20:H53")                                      't   Tableau en BL                 (t  3) = ref, (t  5) = quantité BL
  ReDim a(1 To UBound(t0), 8)
  ReDim a1(1 To UBound(t0))
  ReDim a2(1 To UBound(t0))
  Dim n
  For i = 1 To UBound(a) - 1
      For j = 3 To UBound(t1)      't1 C EST QUI CELUI LA !!!!!!!!!!!!!!!!!!!!!
          'Si entrées moins sorties < qté demandée alors x en col A
          If t1(j, 5) - t1(j, 6) < t0(i, 5) And t1(j, 1) = t0(i, 3) And t0(i, 3) <> "" Then
              a1(i) = t0(i, 3)
              a2(i) = t0(i, 4)
          End If
      Next j
  Next i
[V145].Resize(UBound(a1), 1) = "x"
[Y145].Resize(UBound(a1), 1) = Application.Transpose(a1)
[Z145] .Resize(UBound(a2), 1) = Application.Transpose(a2)
End Sub
 
Dernière édition:

Discussions similaires

Réponses
12
Affichages
241

Statistiques des forums

Discussions
312 079
Messages
2 085 129
Membres
102 788
dernier inscrit
Remy003