Bonjour à tous,
Comment puis-je limiter l'usage d'une macro à une plage de cellules donnée.
Je voudrais que la macro "ZAZA" ne soit utilisable que que si la cellule
active se trouve dans la plage A3 A25.
Comment faire également si ces cellules sont nommées?
Merci à vous
Christian
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Daniel.C
Bonjour. Utilise le code suivant :
If Intersect(ActiveCell, [A3:A25]) Is Nothing Then Exit Sub ou Set Plage = [A3:A25] If Intersect(ActiveCell, Plage) Is Nothing Then Exit Sub
Cordialement. Daniel "Christian de BXL" a écrit dans le message de news:
Bonjour à tous, Comment puis-je limiter l'usage d'une macro à une plage de cellules donnée. Je voudrais que la macro "ZAZA" ne soit utilisable que que si la cellule active se trouve dans la plage A3 A25. Comment faire également si ces cellules sont nommées? Merci à vous Christian
Bonjour.
Utilise le code suivant :
If Intersect(ActiveCell, [A3:A25]) Is Nothing Then Exit Sub
ou
Set Plage = [A3:A25]
If Intersect(ActiveCell, Plage) Is Nothing Then Exit Sub
Cordialement.
Daniel
"Christian de BXL" <ChristiandeBXL@discussions.microsoft.com> a écrit dans
le message de news: 4933652F-349E-433B-94AC-340650D42DD9@microsoft.com...
Bonjour à tous,
Comment puis-je limiter l'usage d'une macro à une plage de cellules
donnée.
Je voudrais que la macro "ZAZA" ne soit utilisable que que si la cellule
active se trouve dans la plage A3 A25.
Comment faire également si ces cellules sont nommées?
Merci à vous
Christian
If Intersect(ActiveCell, [A3:A25]) Is Nothing Then Exit Sub ou Set Plage = [A3:A25] If Intersect(ActiveCell, Plage) Is Nothing Then Exit Sub
Cordialement. Daniel "Christian de BXL" a écrit dans le message de news:
Bonjour à tous, Comment puis-je limiter l'usage d'une macro à une plage de cellules donnée. Je voudrais que la macro "ZAZA" ne soit utilisable que que si la cellule active se trouve dans la plage A3 A25. Comment faire également si ces cellules sont nommées? Merci à vous Christian
Christian de BXL
Bonsoir Daniel, Merci pour ton aide, mais où dois-je mettre ces lignes dans ma macro servant à renvoyer automatiquement un un texte à la ligne dans des cellules fusionnées:
Private Sub Worksheet_Change(ByVal Target As Range) 'Jim Rech, mpep
Dim CurrentRowHeight As Single, MergedCellRgWidth As Single Dim CurrCell As Range Dim targetWidth As Single, PossNewRowHeight As Single
If Target.MergeCells Then With Target.MergeArea .WrapText = True 'enclenche le renvoi à la ligne automatique (modif fs) If .Rows.Count = 1 Then 'And .WrapText = True Then Application.ScreenUpdating = False CurrentRowHeight = .RowHeight targetWidth = Target.ColumnWidth For Each CurrCell In Selection MergedCellRgWidth = CurrCell.ColumnWidth + _ MergedCellRgWidth Next .MergeCells = False .Cells(1).ColumnWidth = MergedCellRgWidth .EntireRow.AutoFit PossNewRowHeight = .RowHeight .Cells(1).ColumnWidth = targetWidth .MergeCells = True .RowHeight = IIf(CurrentRowHeight > PossNewRowHeight, _ CurrentRowHeight, PossNewRowHeight) End If End With End If
End Sub
Dans le cas ou la référence de mes cellules est variables, je pourrais nommer la cellule de début et la cellule de fin de plage. Comment intégrer ces noms? En remplaçant les coordonnées de cellules par ceux-ci ou faut-il leur ajouter un signe quelconque? Merci à toi Christian
Bonsoir Daniel,
Merci pour ton aide, mais où dois-je mettre ces lignes dans ma macro servant
à renvoyer automatiquement un un texte à la ligne dans des cellules
fusionnées:
Private Sub Worksheet_Change(ByVal Target As Range)
'Jim Rech, mpep
Dim CurrentRowHeight As Single, MergedCellRgWidth As Single
Dim CurrCell As Range
Dim targetWidth As Single, PossNewRowHeight As Single
If Target.MergeCells Then
With Target.MergeArea
.WrapText = True 'enclenche le renvoi à la ligne automatique (modif
fs)
If .Rows.Count = 1 Then 'And .WrapText = True Then
Application.ScreenUpdating = False
CurrentRowHeight = .RowHeight
targetWidth = Target.ColumnWidth
For Each CurrCell In Selection
MergedCellRgWidth = CurrCell.ColumnWidth + _
MergedCellRgWidth
Next
.MergeCells = False
.Cells(1).ColumnWidth = MergedCellRgWidth
.EntireRow.AutoFit
PossNewRowHeight = .RowHeight
.Cells(1).ColumnWidth = targetWidth
.MergeCells = True
.RowHeight = IIf(CurrentRowHeight > PossNewRowHeight, _
CurrentRowHeight, PossNewRowHeight)
End If
End With
End If
End Sub
Dans le cas ou la référence de mes cellules est variables, je pourrais
nommer la cellule de début et la cellule de fin de plage. Comment intégrer
ces noms? En remplaçant les coordonnées de cellules par ceux-ci ou faut-il
leur ajouter un signe quelconque?
Merci à toi
Christian
Bonsoir Daniel, Merci pour ton aide, mais où dois-je mettre ces lignes dans ma macro servant à renvoyer automatiquement un un texte à la ligne dans des cellules fusionnées:
Private Sub Worksheet_Change(ByVal Target As Range) 'Jim Rech, mpep
Dim CurrentRowHeight As Single, MergedCellRgWidth As Single Dim CurrCell As Range Dim targetWidth As Single, PossNewRowHeight As Single
If Target.MergeCells Then With Target.MergeArea .WrapText = True 'enclenche le renvoi à la ligne automatique (modif fs) If .Rows.Count = 1 Then 'And .WrapText = True Then Application.ScreenUpdating = False CurrentRowHeight = .RowHeight targetWidth = Target.ColumnWidth For Each CurrCell In Selection MergedCellRgWidth = CurrCell.ColumnWidth + _ MergedCellRgWidth Next .MergeCells = False .Cells(1).ColumnWidth = MergedCellRgWidth .EntireRow.AutoFit PossNewRowHeight = .RowHeight .Cells(1).ColumnWidth = targetWidth .MergeCells = True .RowHeight = IIf(CurrentRowHeight > PossNewRowHeight, _ CurrentRowHeight, PossNewRowHeight) End If End With End If
End Sub
Dans le cas ou la référence de mes cellules est variables, je pourrais nommer la cellule de début et la cellule de fin de plage. Comment intégrer ces noms? En remplaçant les coordonnées de cellules par ceux-ci ou faut-il leur ajouter un signe quelconque? Merci à toi Christian
Daniel.C
Bonsoir.
Private Sub Worksheet_Change(ByVal Target As Range) 'Jim Rech, mpep
Dim CurrentRowHeight As Single, MergedCellRgWidth As Single Dim CurrCell As Range Dim targetWidth As Single, PossNewRowHeight As Single
'****** Là If Intersect(Target, [A3:A25]) Is Nothing Then Exit Sub '******
If Target.MergeCells Then With Target.MergeArea .WrapText = True 'enclenche le renvoi à la ligne automatique (modif fs) If .Rows.Count = 1 Then 'And .WrapText = True Then Application.ScreenUpdating = False CurrentRowHeight = .RowHeight targetWidth = Target.ColumnWidth For Each CurrCell In Selection MergedCellRgWidth = CurrCell.ColumnWidth + _ MergedCellRgWidth Next .MergeCells = False .Cells(1).ColumnWidth = MergedCellRgWidth .EntireRow.AutoFit PossNewRowHeight = .RowHeight .Cells(1).ColumnWidth = targetWidth .MergeCells = True .RowHeight = IIf(CurrentRowHeight > PossNewRowHeight, _ CurrentRowHeight, PossNewRowHeight) End If End With End If
End Sub
Daniel
"Christian de BXL" a écrit dans le message de news:
Bonsoir Daniel, Merci pour ton aide, mais où dois-je mettre ces lignes dans ma macro servant à renvoyer automatiquement un un texte à la ligne dans des cellules fusionnées:
Private Sub Worksheet_Change(ByVal Target As Range) 'Jim Rech, mpep
Dim CurrentRowHeight As Single, MergedCellRgWidth As Single Dim CurrCell As Range Dim targetWidth As Single, PossNewRowHeight As Single
If Target.MergeCells Then With Target.MergeArea .WrapText = True 'enclenche le renvoi à la ligne automatique (modif fs) If .Rows.Count = 1 Then 'And .WrapText = True Then Application.ScreenUpdating = False CurrentRowHeight = .RowHeight targetWidth = Target.ColumnWidth For Each CurrCell In Selection MergedCellRgWidth = CurrCell.ColumnWidth + _ MergedCellRgWidth Next .MergeCells = False .Cells(1).ColumnWidth = MergedCellRgWidth .EntireRow.AutoFit PossNewRowHeight = .RowHeight .Cells(1).ColumnWidth = targetWidth .MergeCells = True .RowHeight = IIf(CurrentRowHeight > PossNewRowHeight, _ CurrentRowHeight, PossNewRowHeight) End If End With End If
End Sub
Dans le cas ou la référence de mes cellules est variables, je pourrais nommer la cellule de début et la cellule de fin de plage. Comment intégrer ces noms? En remplaçant les coordonnées de cellules par ceux-ci ou faut-il leur ajouter un signe quelconque? Merci à toi Christian
Bonsoir.
Private Sub Worksheet_Change(ByVal Target As Range)
'Jim Rech, mpep
Dim CurrentRowHeight As Single, MergedCellRgWidth As Single
Dim CurrCell As Range
Dim targetWidth As Single, PossNewRowHeight As Single
'****** Là
If Intersect(Target, [A3:A25]) Is Nothing Then Exit Sub
'******
If Target.MergeCells Then
With Target.MergeArea
.WrapText = True 'enclenche le renvoi à la ligne automatique (modif
fs)
If .Rows.Count = 1 Then 'And .WrapText = True Then
Application.ScreenUpdating = False
CurrentRowHeight = .RowHeight
targetWidth = Target.ColumnWidth
For Each CurrCell In Selection
MergedCellRgWidth = CurrCell.ColumnWidth + _
MergedCellRgWidth
Next
.MergeCells = False
.Cells(1).ColumnWidth = MergedCellRgWidth
.EntireRow.AutoFit
PossNewRowHeight = .RowHeight
.Cells(1).ColumnWidth = targetWidth
.MergeCells = True
.RowHeight = IIf(CurrentRowHeight > PossNewRowHeight, _
CurrentRowHeight, PossNewRowHeight)
End If
End With
End If
End Sub
Daniel
"Christian de BXL" <ChristiandeBXL@discussions.microsoft.com> a écrit dans
le message de news: 0BE0B064-C870-4B0B-809D-7FDA1AD541E1@microsoft.com...
Bonsoir Daniel,
Merci pour ton aide, mais où dois-je mettre ces lignes dans ma macro
servant
à renvoyer automatiquement un un texte à la ligne dans des cellules
fusionnées:
Private Sub Worksheet_Change(ByVal Target As Range)
'Jim Rech, mpep
Dim CurrentRowHeight As Single, MergedCellRgWidth As Single
Dim CurrCell As Range
Dim targetWidth As Single, PossNewRowHeight As Single
If Target.MergeCells Then
With Target.MergeArea
.WrapText = True 'enclenche le renvoi à la ligne automatique (modif
fs)
If .Rows.Count = 1 Then 'And .WrapText = True Then
Application.ScreenUpdating = False
CurrentRowHeight = .RowHeight
targetWidth = Target.ColumnWidth
For Each CurrCell In Selection
MergedCellRgWidth = CurrCell.ColumnWidth + _
MergedCellRgWidth
Next
.MergeCells = False
.Cells(1).ColumnWidth = MergedCellRgWidth
.EntireRow.AutoFit
PossNewRowHeight = .RowHeight
.Cells(1).ColumnWidth = targetWidth
.MergeCells = True
.RowHeight = IIf(CurrentRowHeight > PossNewRowHeight, _
CurrentRowHeight, PossNewRowHeight)
End If
End With
End If
End Sub
Dans le cas ou la référence de mes cellules est variables, je pourrais
nommer la cellule de début et la cellule de fin de plage. Comment intégrer
ces noms? En remplaçant les coordonnées de cellules par ceux-ci ou faut-il
leur ajouter un signe quelconque?
Merci à toi
Christian
Private Sub Worksheet_Change(ByVal Target As Range) 'Jim Rech, mpep
Dim CurrentRowHeight As Single, MergedCellRgWidth As Single Dim CurrCell As Range Dim targetWidth As Single, PossNewRowHeight As Single
'****** Là If Intersect(Target, [A3:A25]) Is Nothing Then Exit Sub '******
If Target.MergeCells Then With Target.MergeArea .WrapText = True 'enclenche le renvoi à la ligne automatique (modif fs) If .Rows.Count = 1 Then 'And .WrapText = True Then Application.ScreenUpdating = False CurrentRowHeight = .RowHeight targetWidth = Target.ColumnWidth For Each CurrCell In Selection MergedCellRgWidth = CurrCell.ColumnWidth + _ MergedCellRgWidth Next .MergeCells = False .Cells(1).ColumnWidth = MergedCellRgWidth .EntireRow.AutoFit PossNewRowHeight = .RowHeight .Cells(1).ColumnWidth = targetWidth .MergeCells = True .RowHeight = IIf(CurrentRowHeight > PossNewRowHeight, _ CurrentRowHeight, PossNewRowHeight) End If End With End If
End Sub
Daniel
"Christian de BXL" a écrit dans le message de news:
Bonsoir Daniel, Merci pour ton aide, mais où dois-je mettre ces lignes dans ma macro servant à renvoyer automatiquement un un texte à la ligne dans des cellules fusionnées:
Private Sub Worksheet_Change(ByVal Target As Range) 'Jim Rech, mpep
Dim CurrentRowHeight As Single, MergedCellRgWidth As Single Dim CurrCell As Range Dim targetWidth As Single, PossNewRowHeight As Single
If Target.MergeCells Then With Target.MergeArea .WrapText = True 'enclenche le renvoi à la ligne automatique (modif fs) If .Rows.Count = 1 Then 'And .WrapText = True Then Application.ScreenUpdating = False CurrentRowHeight = .RowHeight targetWidth = Target.ColumnWidth For Each CurrCell In Selection MergedCellRgWidth = CurrCell.ColumnWidth + _ MergedCellRgWidth Next .MergeCells = False .Cells(1).ColumnWidth = MergedCellRgWidth .EntireRow.AutoFit PossNewRowHeight = .RowHeight .Cells(1).ColumnWidth = targetWidth .MergeCells = True .RowHeight = IIf(CurrentRowHeight > PossNewRowHeight, _ CurrentRowHeight, PossNewRowHeight) End If End With End If
End Sub
Dans le cas ou la référence de mes cellules est variables, je pourrais nommer la cellule de début et la cellule de fin de plage. Comment intégrer ces noms? En remplaçant les coordonnées de cellules par ceux-ci ou faut-il leur ajouter un signe quelconque? Merci à toi Christian
Christian de BXL
Merci à toi Daniel, je vais essayer de tester cela ce WE. A bientôt Christian
Merci à toi Daniel, je vais essayer de tester cela ce WE.
A bientôt
Christian