Ceci est une page optimisée pour les mobiles. Cliquez sur ce texte pour afficher la vraie page.

Isoler des cellules

  • Initiateur de la discussion Initiateur de la discussion sev
  • Date de début Date de début

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

S

sev

Guest
Bon week end à tous ,
Je voudrais isoler des cellules (A36:F38) contenant des informations pour qu'elles ne parasitent pas l'action du code suivant :

Code:
Private Sub TextBox4_Change() 'BUS ROSE

TextBox12.Value = ""
 TextBox13.Value = ""
 TextBox9.Value = ""
 TextBox38.Value = ""
 TextBox66.Value = ""



Dim MyVar As Long
Dim MyRange As Range, MyCell As Range

    With Me.TextBox4
        Select Case Len(.Value)
               Case 3, 5
                   MyVar = Val(.Value)
               Case Else
                   Exit Sub
        End Select
    End With
    With Sheets("ROSE")
        Set MyRange = Union(.Range(.Range("C6"), .Range("A50").End(xlUp)), _
         .Range(.Range("H6"), .Range("H50").End(xlUp)), _
         .Range(.Range("M6"), .Range("M50").End(xlUp)), _
         .Range(.Range("R6"), .Range("R50").End(xlUp)))
    End With
    
    For Each MyCell In MyRange
        If Val(MyCell) = Val(MyVar) Then
            RunFormat_TextBox9 MyCell.Offset(0, -1)
           RunFormat_TextBox38 MyCell.Offset(0, 2)
            Exit Sub
        End If
    Next
  

End Sub
[CODEPrivate Sub RunFormat_TextBox9(ByRef MyCell As Range) 'TRAIN ROSE


With MyCell
With .Font
MyCellFont = .Name
MyCellFontSize = .Size
MyCellFontColor = .Color
MyCellBold = .Bold
MyCellItalic = .Italic
MyCellUnderLine = .Underline
MyCellValue = MyCell.Value
End With



With Me.TextBox9
With .Font
.Name = MyCellFont
.Bold = MyCellBold
.Italic = MyCellItalic
.Size = MyCellFontSize

End With

.ForeColor = MyCellFontColor
.Value = Format(MyCellValue, "0# ##")
End With


Me.CommandButton2.Visible = True
End With
End Sub



Private Sub RunFormat_TextBox38(ByRef MyCell As Range) 'CASE ROSE


With MyCell
With .Font
MyCellFont = .Name
MyCellFontSize = .Size
MyCellFontColor = .Color
MyCellBold = .Bold
MyCellItalic = .Italic
MyCellUnderLine = .Underline
MyCellValue = MyCell.Value
End With



With Me.TextBox38
With .Font
.Name = MyCellFont
.Bold = MyCellBold
.Italic = MyCellItalic
.Size = MyCellFontSize

End With

.ForeColor = MyCellFontColor
.Value = Application.Replace(MyCellValue, 2, 0, " ")
End With


Me.CommandButton2.Visible = True
End With
End Sub
][/CODE]
 
Re : Isoler des cellules

Je reformule ma demande; il y avvit un problème de forme

Je voudrais isoler des cellules (A36:F38) contenant des informations pour qu'elles ne parasitent pas l'action du code suivant :


Code:
Private Sub TextBox4_Change() 'BUS ROSE

TextBox12.Value = ""
TextBox13.Value = ""
TextBox9.Value = ""
TextBox38.Value = ""
TextBox66.Value = ""



Dim MyVar As Long
Dim MyRange As Range, MyCell As Range

With Me.TextBox4
Select Case Len(.Value)
Case 3, 5
MyVar = Val(.Value)
Case Else
Exit Sub
End Select
End With
With Sheets("ROSE")
Set MyRange = Union(.Range(.Range("C6"), .Range("A50").End(xlUp)), _
.Range(.Range("H6"), .Range("H50").End(xlUp)), _
.Range(.Range("M6"), .Range("M50").End(xlUp)), _
.Range(.Range("R6"), .Range("R50").End(xlUp)))
End With

For Each MyCell In MyRange
If Val(MyCell) = Val(MyVar) Then
RunFormat_TextBox9 MyCell.Offset(0, -1)
RunFormat_TextBox38 MyCell.Offset(0, 2)
Exit Sub
End If
Next


End Sub
Code:
Private Sub RunFormat_TextBox9(ByRef MyCell As Range) 'TRAIN ROSE


With MyCell
With .Font
MyCellFont = .Name
MyCellFontSize = .Size
MyCellFontColor = .Color
MyCellBold = .Bold
MyCellItalic = .Italic
MyCellUnderLine = .Underline
MyCellValue = MyCell.Value
End With



With Me.TextBox9
With .Font
.Name = MyCellFont
.Bold = MyCellBold
.Italic = MyCellItalic
.Size = MyCellFontSize

End With

.ForeColor = MyCellFontColor
.Value = Format(MyCellValue, "0# ##")
End With


Me.CommandButton2.Visible = True
End With
End Sub



Private Sub RunFormat_TextBox38(ByRef MyCell As Range) 'CASE ROSE


With MyCell
With .Font
MyCellFont = .Name
MyCellFontSize = .Size
MyCellFontColor = .Color
MyCellBold = .Bold
MyCellItalic = .Italic
MyCellUnderLine = .Underline
MyCellValue = MyCell.Value
End With



With Me.TextBox38
With .Font
.Name = MyCellFont
.Bold = MyCellBold
.Italic = MyCellItalic
.Size = MyCellFontSize

End With

.ForeColor = MyCellFontColor
.Value = Application.Replace(MyCellValue, 2, 0, " ")
End With


Me.CommandButton2.Visible = True
End With
End Sub
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD
Assurez vous de marquer un message comme solution pour une meilleure transparence.

Discussions similaires

B
  • Question Question
Réponses
10
Affichages
1 K
Batourouciss
B
Réponses
1
Affichages
1 K
C
Réponses
4
Affichages
1 K
Carlich
C
A
Réponses
10
Affichages
2 K
A
Réponses
0
Affichages
845
Les cookies sont requis pour utiliser ce site. Vous devez les accepter pour continuer à utiliser le site. En savoir plus…