[RESOLUTO]Simplifier un code

Ilino

XLDnaute Barbatruc
Forum Bonsoir
je veux simplifier ce code ci dessous pour le généralisé (un petit code a simplifier ... !!!!)grazie par avance
Code:
If Not Intersect(Rows(Target.Row), [F32]) Is Nothing Then
      Application.ScreenUpdating = False
      n1 = CInt([F32])
      Rows("45:74").Hidden = True
      Select Case n1
         Case 1
            Rows("45:51").Hidden = False
         Case 2
            Rows("45:52").Hidden = False
         Case 3
            Rows("45:53").Hidden = False
         Case 4
            Rows("45:54").Hidden = False
         Case 5
            Rows("45:55").Hidden = False
         Case 6
            Rows("45:56").Hidden = False
         Case 7
            Rows("45:57").Hidden = False
         Case 8
            Rows("45:58").Hidden = False
         Case 9
            Rows("45:59").Hidden = False
         Case 10
            Rows("45:60").Hidden = False
         Case 11
            Rows("45:61").Hidden = False
         Case 12
            Rows("45:62").Hidden = False
         Case 13
            Rows("45:63").Hidden = False
         Case 14
            Rows("45:64").Hidden = False
         Case 15
            Rows("45:65").Hidden = False
        Case 16
            Rows("45:66").Hidden = False
        Case 17
            Rows("45:67").Hidden = False
        Case 18
            Rows("45:68").Hidden = False
        Case 19
            Rows("45:69").Hidden = False
        Case 20
            Rows("45:70").Hidden = False
        Case 21
            Rows("45:71").Hidden = False
        Case 22
            Rows("45:72").Hidden = False
        Case 23
        Case 24
            Rows("45:74").Hidden = False
     End Select
   
   End If
   
   
   If Not Intersect(Rows(Target.Row), [F33]) Is Nothing Then
      Application.ScreenUpdating = False
      n2 = CInt([F33])
      Rows("76:105").Hidden = True
      Select Case n2
         Case 1
            Rows("76:82").Hidden = False
         Case 2
            Rows("76:83").Hidden = False
         Case 3
            Rows("76:84").Hidden = False
         Case 4
            Rows("76:85").Hidden = False
         Case 5
            Rows("76:86").Hidden = False
         Case 6
            Rows("76:87").Hidden = False
        Case 7
            Rows("76:88").Hidden = False
        Case 8
            Rows("76:89").Hidden = False
        Case 9
            Rows("76:90").Hidden = False
        Case 10
            Rows("76:91").Hidden = False
        Case 11
            Rows("76:92").Hidden = False
        Case 12
            Rows("76:93").Hidden = False
        Case 13
            Rows("76:94").Hidden = False
        Case 14
            Rows("76:95").Hidden = False
        Case 15
            Rows("76:96").Hidden = False
        Case 16
            Rows("76:97").Hidden = False
        Case 17
            Rows("76:98").Hidden = False
        Case 18
            Rows("76:99").Hidden = False
        Case 19
            Rows("76:100").Hidden = False
        Case 20
            Rows("76:101").Hidden = False
        Case 21
            Rows("76:102").Hidden = False
        Case 22
            Rows("76:103").Hidden = False
        Case 23
            Rows("76:104").Hidden = False
        Case 24
            Rows("76:105").Hidden = False
            
      End Select
   
   End If
Que dois je faire
grazie
A+
 
Dernière édition:

mapomme

XLDnaute Barbatruc
Supporter XLD
Re : Simplifier un code

Bonsoir Ilino,

Ceci peut-être (pas testé):
Code:
If Not Intersect(Rows(Target.Row), [F32]) Is Nothing Then
  Application.ScreenUpdating = False
  Rows("45:74").Hidden = True
  Select Case CInt([F32])
  Case 1 To 22, 24
    Rows("45:" & (50 + CInt([F32]))).Hidden = False
  End Select
End If

If Not Intersect(Rows(Target.Row), [F33]) Is Nothing Then
  Application.ScreenUpdating = False
  Rows("76:105").Hidden = True
  Select Case CInt([F33])
  Case 1 To 24
    Rows("76:" & (81 + CInt([F33]))).Hidden = False
  End Select
End If
 
Dernière édition:

Discussions similaires

Réponses
3
Affichages
702

Statistiques des forums

Discussions
314 611
Messages
2 111 145
Membres
111 051
dernier inscrit
MANUREVALAND