Macro sélectionner une feuille selon valeur d'une cellule

Usine à gaz

XLDnaute Barbatruc
Supporter XLD
Bonjour à tous et (même si c'est un peu tardif), je vous souhaite un bon samedi,

je bute sur un nouveau problème et j'ai besoin de votre aide.

Voici ce que je voudrais faire en macro :

If ma feuille OF1 cellule C1 = ma feuille Cal cellule E1 Then Sheets("Cal").Select

Un grand merci pour votre aide.

Amicalement,
Lionel,
 

Papou-net

XLDnaute Barbatruc
Re : Macro sélectionner une feuille selon valeur d'une cellule

Bonsoir Lionel,

Ca devrait le faire comme ceci :

Code:
If Sheets("OF1").Range("C1").Value = Sheets("Cal").Range("E1").Value Then Sheets("Cal").Activate
Cordialement.
 

Usine à gaz

XLDnaute Barbatruc
Supporter XLD
Re : Macro sélectionner une feuille selon valeur d'une cellule

Re et à tous,

Merci pour ces mots.

j'ai fait cette macro mais elle ne marche pas et bloque : Bloc IF sans End If

___________________________________________________________________

Sub CopieOF()
'
' CopieOF Macro
'

'

Application.ScreenUpdating = False

If Sheets("OF1").Range("C1") = Sheets("Cal").Range("E1").Value Then
Sheets("Cal").Select
If Sheets("OF1").Range("C1") = Sheets("Cot").Range("E1").Value Then
Sheets("Cot").Select
If Sheets("OF1").Range("C1") = Sheets("ITW").Range("E1").Value Then
Sheets("ITW").Select
If Sheets("OF1").Range("C1") = Sheets("NEX").Range("E1").Value Then
Sheets("NEX").Select
If Sheets("OF1").Range("C1") = Sheets("STI").Range("E1").Value Then
Sheets("STI").Select
End If
If [ke1] > 0 Then Call CopieOF25
If [js1] > 0 Then Call CopieOF24
If [jg1] > 0 Then Call CopieOF23
If [iu1] > 0 Then Call CopieOF22
If [ii1] > 0 Then Call CopieOF21
If [hw1] > 0 Then Call CopieOF20
If [hk1] > 0 Then Call CopieOF19
If [gy1] > 0 Then Call CopieOF18
If [gm1] > 0 Then Call CopieOF17
If [ga1] > 0 Then Call CopieOF16
If [fo1] > 0 Then Call CopieOF15
If [fc1] > 0 Then Call CopieOF14
If [eq1] > 0 Then Call CopieOF13
If [ee1] > 0 Then Call CopieOF12
If [ds1] > 0 Then Call CopieOF11
If [dg1] > 0 Then Call CopieOF10
If [cu1] > 0 Then Call CopieOF9
If [ci1] > 0 Then Call CopieOF8
If [bw1] > 0 Then Call CopieOF7
If [bk1] > 0 Then Call CopieOF6
If [ay1] > 0 Then Call CopieOF5
If [am1] > 0 Then Call CopieOF4
If [aa1] > 0 Then Call CopieOF3
If [o1] > 0 Then Call CopieOF2
If [c1] > 0 Then Call CopieOF1
End If
Exit Sub
Application.EnableEvents = True
End Sub

_________________________________________________________________________

Je me noie dans les IF,

Encore merci pour votre aide,
Amicalement,
Lionel,
 

Staple1600

XLDnaute Barbatruc
Re : Macro sélectionner une feuille selon valeur d'une cellule

Bonsoir à tous


Une autre pour le fun (et pour le plaisir de croiser les anciens ;) )

Code:
Sub activefeuille()
Dim f As Worksheet: Set f = Sheets("Cal")
Application.Goto IIf((Sheets("OF1").[C1] = f.[E1].Value), f.[A1], ActiveSheet.[A1])
End Sub
 

JBARBE

XLDnaute Barbatruc
Re : Macro sélectionner une feuille selon valeur d'une cellule

Essayer ceci !

Mais pour moins compliquer la macro on peut faire :
Code:
dim i as integer

for i = 1 to 5
If Sheets("OF1").Range("C1") = Sheets(i).Range("E1").Value Then ' sheets (i) étant la 1ere feuille si c'est la    
                                                                                               ' 2eme mettre for i = 2 to 6
end if
next i


Code:
If Sheets("OF1").Range("C1") = Sheets("Cal").Range("E1").Value Then
Sheets("Cal").Select
End If
If Sheets("OF1").Range("C1") = Sheets("Cot").Range("E1").Value Then
Sheets("Cot").Select
End If
If Sheets("OF1").Range("C1") = Sheets("ITW").Range("E1").Value Then
Sheets("ITW").Select
End If
If Sheets("OF1").Range("C1") = Sheets("NEX").Range("E1").Value Then
Sheets("NEX").Select
End If
If Sheets("OF1").Range("C1") = Sheets("STI").Range("E1").Value Then
Sheets("STI").Select
End If
If [ke1] > 0 Then Call CopieOF25
End If
If [js1] > 0 Then Call CopieOF24
End If
If [jg1] > 0 Then Call CopieOF23
End If
If [iu1] > 0 Then Call CopieOF22
End If
If [ii1] > 0 Then Call CopieOF21
End If
If [hw1] > 0 Then Call CopieOF20
End If
If [hk1] > 0 Then Call CopieOF19
End If
If [gy1] > 0 Then Call CopieOF18
End If
If [gm1] > 0 Then Call CopieOF17
End If
If [ga1] > 0 Then Call CopieOF16
End If
If [fo1] > 0 Then Call CopieOF15
End If
If [fc1] > 0 Then Call CopieOF14
End If
If [eq1] > 0 Then Call CopieOF13
End If
If [ee1] > 0 Then Call CopieOF12
End If
If [ds1] > 0 Then Call CopieOF11
End If
If [dg1] > 0 Then Call CopieOF10
End If
If [cu1] > 0 Then Call CopieOF9
End If
If [ci1] > 0 Then Call CopieOF8
End If
If [bw1] > 0 Then Call CopieOF7
End If
If [bk1] > 0 Then Call CopieOF6
End If
If [ay1] > 0 Then Call CopieOF5
End If
If [am1] > 0 Then Call CopieOF4
End If
If [aa1] > 0 Then Call CopieOF3
End If
If [o1] > 0 Then Call CopieOF2
End If
If [c1] > 0 Then Call CopieOF1
End If
Exit Sub
Application.EnableEvents = True
End Sub
 
Dernière édition:

Discussions similaires

Statistiques des forums

Discussions
312 194
Messages
2 086 064
Membres
103 110
dernier inscrit
Privé