Bonjour le Forum, et re-bonjour Thierry !
hé oui, pour ceux qui ne le savent pas encore, les trois lettres 'USF' sont un appeau spécial Thierry, selon une formule que j'ai vu dans un post aujourd'hui !
Voici mon soucis : la procédure ci-dessous fonctionne :
Sub Macro1()
'
Dim source As Workbook
Dim trame As Workbook
Dim propositions() As String
Dim propositions2() As String
Dim C As Range
Dim i As Integer, j As Integer
Dim Firstaddress As String
Set source = Workbooks(Workbooks.Count)
Set trame = Workbooks(Workbooks.Count - 1)
source.Activate
Set nomfcp = Range('FCP')
rechCol.TextBox1.Value = nomfcp
With trame.Sheets('trame').Range('B5:BZ5')
Set C = .Find(Left(rechCol.TextBox1.Value, Len(rechCol.TextBox1) - 16), _
LookIn:=xlValues)
If Not C Is Nothing Then
Firstaddress = C.Address
Do
ReDim Preserve propositions(1, i)
propositions(0, i) = C.Value
propositions(1, i) = C.Column
i = i + 1
Set C = .FindNext(C)
Loop While Not C Is Nothing And C.Address <> Firstaddress
End If
End With
ReDim propositions2(0 To UBound(propositions, 2), 0 To UBound(propositions, 1))
For i = LBound(propositions, 2) To UBound(propositions, 2)
propositions2(i, 0) = propositions(0, i)
propositions2(i, 1) = propositions(1, i)
Next i
With rechCol.ListBox1
.ColumnCount = 2
.ColumnWidths = '200;10'
.List() = propositions2
End With
rechCol.Show
End Sub
Ceci me permet de faire apparaître mon USF avec une listbox en deux colonnes avec des noms et des n° de colonnes.
Mon problème est que si je reprend l'essentiel de ce code dans l'initialize de mon USF, cela ne marche pas !
A savoir, voici la macro appelante :
Option Explicit
Public nomfcp As Variant
Public source As Workbook
Public trame As Workbook
Sub Macro2()
Set source = Workbooks(Workbooks.Count)
Set trame = Workbooks(Workbooks.Count - 1)
source.Activate
Set nomfcp = Range('FCP')
rechCol.TextBox1.Value = nomfcp
rechCol.Show
Et voici l'initialize :
Option Explicit
Private Sub rechCol_Initialize()
Dim propositions() As String
Dim propositions2() As String
Dim C As Range
Dim i As Integer, j As Integer
Dim Firstaddress As String
With trame.Sheets('trame').Range('B5:BZ5')
Set C = .Find(Left(rechCol.TextBox1.Value, Len(rechCol.TextBox1) - 16), _
LookIn:=xlValues)
If Not C Is Nothing Then
Firstaddress = C.Address
Do
ReDim Preserve propositions(1, i)
propositions(0, i) = C.Value
propositions(1, i) = C.Column
i = i + 1
Set C = .FindNext(C)
Loop While Not C Is Nothing And C.Address <> Firstaddress
End If
End With
ReDim propositions2(0 To UBound(propositions, 2), 0 To UBound(propositions, 1))
For i = LBound(propositions, 2) To UBound(propositions, 2)
propositions2(i, 0) = propositions(0, i)
propositions2(i, 1) = propositions(1, i)
Next i
With rechCol.ListBox1
.ColumnCount = 2
.ColumnWidths = '200;10'
.List() = propositions2
End With
End Sub
Quand je lance ma macro2, je n'ai que la textbox remplie, et rien dans la listbox 🙁
Alors, il est où le problème ??
Heureusement que vous êtes là, sinon j'aurai du mal à m'accrocher !
hé oui, pour ceux qui ne le savent pas encore, les trois lettres 'USF' sont un appeau spécial Thierry, selon une formule que j'ai vu dans un post aujourd'hui !
Voici mon soucis : la procédure ci-dessous fonctionne :
Sub Macro1()
'
Dim source As Workbook
Dim trame As Workbook
Dim propositions() As String
Dim propositions2() As String
Dim C As Range
Dim i As Integer, j As Integer
Dim Firstaddress As String
Set source = Workbooks(Workbooks.Count)
Set trame = Workbooks(Workbooks.Count - 1)
source.Activate
Set nomfcp = Range('FCP')
rechCol.TextBox1.Value = nomfcp
With trame.Sheets('trame').Range('B5:BZ5')
Set C = .Find(Left(rechCol.TextBox1.Value, Len(rechCol.TextBox1) - 16), _
LookIn:=xlValues)
If Not C Is Nothing Then
Firstaddress = C.Address
Do
ReDim Preserve propositions(1, i)
propositions(0, i) = C.Value
propositions(1, i) = C.Column
i = i + 1
Set C = .FindNext(C)
Loop While Not C Is Nothing And C.Address <> Firstaddress
End If
End With
ReDim propositions2(0 To UBound(propositions, 2), 0 To UBound(propositions, 1))
For i = LBound(propositions, 2) To UBound(propositions, 2)
propositions2(i, 0) = propositions(0, i)
propositions2(i, 1) = propositions(1, i)
Next i
With rechCol.ListBox1
.ColumnCount = 2
.ColumnWidths = '200;10'
.List() = propositions2
End With
rechCol.Show
End Sub
Ceci me permet de faire apparaître mon USF avec une listbox en deux colonnes avec des noms et des n° de colonnes.
Mon problème est que si je reprend l'essentiel de ce code dans l'initialize de mon USF, cela ne marche pas !
A savoir, voici la macro appelante :
Option Explicit
Public nomfcp As Variant
Public source As Workbook
Public trame As Workbook
Sub Macro2()
Set source = Workbooks(Workbooks.Count)
Set trame = Workbooks(Workbooks.Count - 1)
source.Activate
Set nomfcp = Range('FCP')
rechCol.TextBox1.Value = nomfcp
rechCol.Show
Et voici l'initialize :
Option Explicit
Private Sub rechCol_Initialize()
Dim propositions() As String
Dim propositions2() As String
Dim C As Range
Dim i As Integer, j As Integer
Dim Firstaddress As String
With trame.Sheets('trame').Range('B5:BZ5')
Set C = .Find(Left(rechCol.TextBox1.Value, Len(rechCol.TextBox1) - 16), _
LookIn:=xlValues)
If Not C Is Nothing Then
Firstaddress = C.Address
Do
ReDim Preserve propositions(1, i)
propositions(0, i) = C.Value
propositions(1, i) = C.Column
i = i + 1
Set C = .FindNext(C)
Loop While Not C Is Nothing And C.Address <> Firstaddress
End If
End With
ReDim propositions2(0 To UBound(propositions, 2), 0 To UBound(propositions, 1))
For i = LBound(propositions, 2) To UBound(propositions, 2)
propositions2(i, 0) = propositions(0, i)
propositions2(i, 1) = propositions(1, i)
Next i
With rechCol.ListBox1
.ColumnCount = 2
.ColumnWidths = '200;10'
.List() = propositions2
End With
End Sub
Quand je lance ma macro2, je n'ai que la textbox remplie, et rien dans la listbox 🙁
Alors, il est où le problème ??
Heureusement que vous êtes là, sinon j'aurai du mal à m'accrocher !