Aide sur un combobox fonctionnalité

Résolu/Fermé
Cedric_hess Messages postés 28 Date d'inscription mercredi 30 mars 2016 Statut Membre Dernière intervention 24 mai 2016 - Modifié par Cedric_hess le 22/04/2016 à 11:11
Cedric_hess Messages postés 28 Date d'inscription mercredi 30 mars 2016 Statut Membre Dernière intervention 24 mai 2016 - 22 avril 2016 à 11:15
Bonjour tout le monde ,

j'ai besoin de votre aide SVP ,sur mon userform j'ai deux combobox chaqu'un me permet de choisir une feuille dans mon fichier excel enfaite ce que je veux c'est quand je choisis les deux feuilles des deux combobox qu'on puisse copier toutes les colonnes des deux feuilles dans une autre feuille dans le meme fichier excel est ce que c'est possible de faire ca merci

Voila le code VBA que j'utilise pour choisire du combobox :

Private Sub ComboBox1_Change()
Const ColItems As Long = 20
Const LetterWidth As Long = 20
Const HeightRowz As Long = 18
Const SheetID As String = "__SheetSelection"

Dim i%, TopPos%, iSet%, optCols%, intLetters%, optMaxChars%, optLeft%
Dim wsDlg As DialogSheet, objOpt As OptionButton, optCaption$, objSheet As Object
optCaption = "": i = 0

Application.ScreenUpdating = False

On Error Resume Next
Application.DisplayAlerts = False
ActiveWorkbook.DialogSheets(SheetID).Delete
Application.DisplayAlerts = True
Err.Clear

Set wsDlg = ActiveWorkbook.DialogSheets.Add
With wsDlg
.Name = SheetID
.Visible = xlSheetHidden
iSet = 0: optCols = 0: optMaxChars = 0: optLeft = 78: TopPos = 40

For Each objSheet In ActiveWorkbook.Sheets
If objSheet.Visible = xlSheetVisible Then
i = i + 1

If i Mod ColItems = 1 Then
optCols = optCols + 1
TopPos = 40
optLeft = optLeft + (optMaxChars * LetterWidth)
optMaxChars = 0
End If

intLetters = Len(objSheet.Name)
If intLetters > optMaxChars Then optMaxChars = intLetters
iSet = iSet + 1
.OptionButtons.Add optLeft, TopPos, intLetters * LetterWidth, 16.5
.OptionButtons(iSet).Text = objSheet.Name
TopPos = TopPos + 13

End If
Next objSheet

If i > 0 Then

.Buttons.Left = optLeft + (optMaxChars * LetterWidth) + 24

With .DialogFrame
.Height = Application.Max(68, WorksheetFunction.Min(iSet, ColItems) * HeightRowz + 10)
.Width = optLeft + (optMaxChars * LetterWidth) + 24
.Caption = "Select sheet to go to"
End With

.Buttons("Button 2").BringToFront
.Buttons("Button 3").BringToFront
Application.ScreenUpdating = True

If .Show = True Then
For Each objOpt In wsDlg.OptionButtons
If objOpt.Value = xlOn Then
optCaption = objOpt.Caption
Exit For
End If
Next objOpt
End If

If optCaption = "" Then
MsgBox "You did not select a worksheet.", 48, "Cannot continue"
Exit Sub
Else

MsgBox "You selected the sheet named ''" & optCaption & "''." & vbCrLf & "Click OK to go there.", 64, "FYI:"
Sheets(optCaption).Activate

End If

End If

Application.DisplayAlerts = False
.Delete
Application.DisplayAlerts = True

End With
End Sub


et voila le fichier excel sur lequelle je travaille :cjoint.com/c/FDvl1kkSHcv

1 réponse

Cedric_hess Messages postés 28 Date d'inscription mercredi 30 mars 2016 Statut Membre Dernière intervention 24 mai 2016
22 avril 2016 à 11:15
rebonjour tt le monde

voila la solution pour ceux qui sont interessées il faut just remplacer cette partie de code
 Sheets(optCaption).Activate
par
Sheets(optCaption).Range("A1:F10000").copy Destination:=Sheets("operations").Range("A1:F10000") 
et ca copie les colonnes de la feuille qu'on select dans le combobox dans la feuille operation
0