Problème code VBA cellules fusionnes
d
Bonjour,
j'essaye de mettre en place un code VBA mais je peine...
Ce code, j'explique met en forme un tableau. Cependant dans ce tableau, des cellules sont fusionnées. J'aimerais que ce code VBA, puisse interroger chaque ligne de mon tableau. Lorsque la cellule est fusionnées il applique un format et lorsque les cellules ne sont pas fusionnées il applique un autre format a chaque cellule de la ligne...
Merci d'avance...
Sub MiseEnFormeSuiviComptesBancaires()
Dim L As Long
Dim x As Long
L = Sheets("ActiveSheet").Range("D65000").End(xlUp).Row + 1
Do While x < 1000000
x = x + 1
If Range("D" & L).MergeArea = 1 Then 'Si cellules de D à H sont fusionnées alors faire '
With Range("D" & L).MergeArea
With .Font
.Name = "Arial Black"
.Size = 16
.Italic = True
.Bold = True
End With
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.RowHeight = 21
End With
Else
With ActiveSheets
With Range("D9:D100000")
With .Font
.Name = "Arial Black "
.Size = 10
.Italic = True
.Bold = True
End With
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.RowHeight = 15
End With
With Range("E9:F100000").Font
.Name = "Arial "
.Size = 10
.Underline = xlUnderlineStyleNone
.Italic = True
End With
With Range("G9:H100000").Font
.Name = "Arial "
.Size = 10
.Underline = xlUnderlineStyleNone
.Italic = True
End With
Range("G9:H100000").NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* ""-""??_);_(@_)"
End With
End If
Exit Do
Loop
Loop Until Range("D" & L) = "" Or x = 1000000
End Subbonjour,
sur base de ce que j'ai compris
Sub MiseEnFormeSuiviComptesBancaires()
Dim L As Long
Dim x As Long
With ActiveSheet
L = .Range("D" & Rows.Count).End(xlUp).Row + 1
For i = 9 To L
If .Range("D" & i).MergeArea.Count > 1 Then 'Si cellules de D à H sont fusionnées alors faire '
With .Range("D" & i).MergeArea
With .Font
.Name = "Arial Black"
.Size = 16
.Italic = True
.Bold = True
End With
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.RowHeight = 21
End With
Else
With .Range("D" & i)
With .Font
.Name = "Arial Black "
.Size = 10
.Italic = True
.Bold = True
End With
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.RowHeight = 15
End With
With .Range("E" & i & ":F" & i).Font
.Name = "Arial "
.Size = 10
.Underline = xlUnderlineStyleNone
.Italic = True
End With
With .Range("G" & i & ":H" & i).Font
.Name = "Arial "
.Size = 10
.Underline = xlUnderlineStyleNone
.Italic = True
End With
End If
Next i
.Range("G9:H" & L).NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* ""-""??_);_(@_)"
End With
End Subd
Celui ci est le bon code, et c'est celui que je voulais. Cependant quand je l'applique il fonctionne mais il fait beuger excel.... Savez vous pourquoi ?