Nom du classeur contenant la macro en variable dans cette dernière
3 réponses
snoopix
Bonjour, et bonne année !
Je bute sur un problème qui me paraît insoluble, d'où mon inscription et ma demande d'aide !
Dans un classeur ouvert, un bouton active une macro, qui doit ouvrir un autre classeur ("Honoraires 2009") et récupérer dans le premier (celui de la macro "INDIVISION 1") des valeurs sur la feuille ("Fiche locataire") pour les insérer dans ("Honoraires 2009").
La macro fonctionne, la voici :
Private Sub CommandButton6_Click()
'
' HonorairesMiseLocation Macro
'
ActiveCell.FormulaR1C1 = "='[ThisWorkbook]FICHE LOCATAIRE'!R42C8"
Sheets("Facturation").Range("C18:G18").Select
ActiveCell.FormulaR1C1 = "='[ThisWorkbook]FICHE LOCATAIRE'!R13C3:R13C6"
Sheets("Facturation").Range("C20:G20").Select
ActiveCell.FormulaR1C1 = "='[ThisWorkbook]FICHE LOCATAIRE'!R21C3:R21C6"
Sheets("Facturation").Range("C22:G22").Select
ActiveCell.FormulaR1C1 = "='[ThisWorkbook]FICHE LOCATAIRE'!R29C3:R29C6"
Sheets("Facturation").Range("D25:F25").Select
ActiveCell.FormulaR1C1 = "='[ThisWorkbook]FICHE LOCATAIRE'!R42C4"
Sheets("Facturation").Range("D26").Select
Sheets("HONORAIRES DE MISE EN LOCATION").Select
Sheets("HONORAIRES DE MISE EN LOCATION").Range("L12").Select
End Sub
Je voudrais pouvoir remplacer le nom du classeur contenant la macro, à savoir "INDIVISION 1" par une variable qui prendrait elle même le nom de ce classeur, sans le nommer.
Ceci dans le but de pouvoir dupliquer un grand nombre de foi le classeur contenant la macro, sans devoir corriger à chaque foi le code de chaque classeur.
C'est long, mais j'ai essayer d'être clair.
Si vous avez déjà eu le cas ... merci de votre aide.
Je n'ai pas trouver d'exemple utilisable pour ce cas ...
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
snoopix
snoopix a écrit le 19/01/2010 à 23h33 :
Bonjour, et bonne année !
Je bute sur un problème qui me paraît insoluble, d'où mon inscription et ma demande d'aide ! Dans un classeur ouvert, un bouton active une macro, qui doit ouvrir un autre classeur ("Honoraires 2009") et récupérer dans le premier (celui de la macro "INDIVISION 1") des valeurs sur la feuille ("Fiche locataire") pour les insérer dans ("Honoraires 2009").
La macro fonctionne, la voici :
Private Sub CommandButton6_Click() ' ' HonorairesMiseLocation Macro '
ActiveCell.FormulaR1C1 = "='[ThisWorkbook]FICHE LOCATAIRE'!R42C8" Sheets("Facturation").Range("C18:G18").Select ActiveCell.FormulaR1C1 = "='[ThisWorkbook]FICHE LOCATAIRE'!R13C3:R13C6" Sheets("Facturation").Range("C20:G20").Select ActiveCell.FormulaR1C1 = "='[ThisWorkbook]FICHE LOCATAIRE'!R21C3:R21C6" Sheets("Facturation").Range("C22:G22").Select ActiveCell.FormulaR1C1 = "='[ThisWorkbook]FICHE LOCATAIRE'!R29C3:R29C6" Sheets("Facturation").Range("D25:F25").Select ActiveCell.FormulaR1C1 = "='[ThisWorkbook]FICHE LOCATAIRE'!R42C4" Sheets("Facturation").Range("D26").Select Sheets("HONORAIRES DE MISE EN LOCATION").Select Sheets("HONORAIRES DE MISE EN LOCATION").Range("L12").Select
End Sub
Je voudrais pouvoir remplacer le nom du classeur contenant la macro, à savoir "INDIVISION 1" par une variable qui prendrait elle même le nom de ce classeur, sans le nommer. Ceci dans le but de pouvoir dupliquer un grand nombre de foi le classeur contenant la macro, sans devoir corriger à chaque foi le code de chaque classeur.
C'est long, mais j'ai essayer d'être clair.
Si vous avez déjà eu le cas ... merci de votre aide. Je n'ai pas trouver d'exemple utilisable pour ce cas ...
La macro contient une erreur, à la place de ThisWorKbook, c'est INDIVISION 1 ... J'avais essayé ...
snoopix a écrit le 19/01/2010 à 23h33 :
Bonjour, et bonne année !
Je bute sur un problème qui me paraît insoluble, d'où mon
inscription et ma demande d'aide !
Dans un classeur ouvert, un bouton active une macro, qui doit ouvrir un autre
classeur ("Honoraires 2009") et récupérer dans le
premier (celui de la macro "INDIVISION 1") des valeurs sur la feuille
("Fiche locataire") pour les insérer dans ("Honoraires
2009").
La macro fonctionne, la voici :
Private Sub CommandButton6_Click()
'
' HonorairesMiseLocation Macro
'
ActiveCell.FormulaR1C1 = "='[ThisWorkbook]FICHE
LOCATAIRE'!R42C8"
Sheets("Facturation").Range("C18:G18").Select
ActiveCell.FormulaR1C1 = "='[ThisWorkbook]FICHE
LOCATAIRE'!R13C3:R13C6"
Sheets("Facturation").Range("C20:G20").Select
ActiveCell.FormulaR1C1 = "='[ThisWorkbook]FICHE
LOCATAIRE'!R21C3:R21C6"
Sheets("Facturation").Range("C22:G22").Select
ActiveCell.FormulaR1C1 = "='[ThisWorkbook]FICHE
LOCATAIRE'!R29C3:R29C6"
Sheets("Facturation").Range("D25:F25").Select
ActiveCell.FormulaR1C1 = "='[ThisWorkbook]FICHE
LOCATAIRE'!R42C4"
Sheets("Facturation").Range("D26").Select
Sheets("HONORAIRES DE MISE EN LOCATION").Select
Sheets("HONORAIRES DE MISE EN
LOCATION").Range("L12").Select
End Sub
Je voudrais pouvoir remplacer le nom du classeur contenant la macro, à
savoir "INDIVISION 1" par une variable qui prendrait elle même
le nom de ce classeur, sans le nommer.
Ceci dans le but de pouvoir dupliquer un grand nombre de foi le classeur
contenant la macro, sans devoir corriger à chaque foi le code de chaque
classeur.
C'est long, mais j'ai essayer d'être clair.
Si vous avez déjà eu le cas ... merci de votre aide.
Je n'ai pas trouver d'exemple utilisable pour ce cas ...
La macro contient une erreur, à la place de ThisWorKbook, c'est INDIVISION 1 ...
J'avais essayé ...
Je bute sur un problème qui me paraît insoluble, d'où mon inscription et ma demande d'aide ! Dans un classeur ouvert, un bouton active une macro, qui doit ouvrir un autre classeur ("Honoraires 2009") et récupérer dans le premier (celui de la macro "INDIVISION 1") des valeurs sur la feuille ("Fiche locataire") pour les insérer dans ("Honoraires 2009").
La macro fonctionne, la voici :
Private Sub CommandButton6_Click() ' ' HonorairesMiseLocation Macro '
ActiveCell.FormulaR1C1 = "='[ThisWorkbook]FICHE LOCATAIRE'!R42C8" Sheets("Facturation").Range("C18:G18").Select ActiveCell.FormulaR1C1 = "='[ThisWorkbook]FICHE LOCATAIRE'!R13C3:R13C6" Sheets("Facturation").Range("C20:G20").Select ActiveCell.FormulaR1C1 = "='[ThisWorkbook]FICHE LOCATAIRE'!R21C3:R21C6" Sheets("Facturation").Range("C22:G22").Select ActiveCell.FormulaR1C1 = "='[ThisWorkbook]FICHE LOCATAIRE'!R29C3:R29C6" Sheets("Facturation").Range("D25:F25").Select ActiveCell.FormulaR1C1 = "='[ThisWorkbook]FICHE LOCATAIRE'!R42C4" Sheets("Facturation").Range("D26").Select Sheets("HONORAIRES DE MISE EN LOCATION").Select Sheets("HONORAIRES DE MISE EN LOCATION").Range("L12").Select
End Sub
Je voudrais pouvoir remplacer le nom du classeur contenant la macro, à savoir "INDIVISION 1" par une variable qui prendrait elle même le nom de ce classeur, sans le nommer. Ceci dans le but de pouvoir dupliquer un grand nombre de foi le classeur contenant la macro, sans devoir corriger à chaque foi le code de chaque classeur.
C'est long, mais j'ai essayer d'être clair.
Si vous avez déjà eu le cas ... merci de votre aide. Je n'ai pas trouver d'exemple utilisable pour ce cas ...
La macro contient une erreur, à la place de ThisWorKbook, c'est INDIVISION 1 ... J'avais essayé ...
FdeCourt
Salut,
Essayes avec cette macros
Private Sub CommandButton6_Click() ' ' HonorairesMiseLocation Macro ' Dim honoraires As Workbook Dim facturation As Worksheet Dim monFichier As String
monFichier = ThisWorkbook.Path & "[" & ThisWorkbook.Name & "]" Set honoraires = Workbooks.Open(Filename:="E:EDIRFA 2009HONORAIRES 2009A") Set facturation = honoraires.Sheets("Facturation")
With facturation .Range("C16").FormulaR1C1 = "='" & monFichier & "FICHE LOCATAIRE'!R42C8" .Range("C18:G18").FormulaR1C1 = "='" & monFichier & "FICHE LOCATAIRE'!R13C3:R13C6" .Range("C20:G20").FormulaR1C1 = "='" & monFichier & "FICHE LOCATAIRE'!R21C3:R21C6" .Range("C22:G22").FormulaR1C1 = "='" & monFichier & "FICHE LOCATAIRE'!R29C3:R29C6" .Range("D25:F25").FormulaR1C1 = "='" & monFichier & "FICHE LOCATAIRE'!R42C4" End With honoraires.Sheets("HONORAIRES DE MISE EN LOCATION").Select honoraires.Sheets("HONORAIRES DE MISE EN LOCATION").Range ("L12").Select Set honoraires = Nothing: Set facturation = Nothing End Sub
Ceci dit, je ne comprend pas trop l'intérêt des formules !!!!
Cordialement,
F.
Salut,
Essayes avec cette macros
Private Sub CommandButton6_Click()
'
' HonorairesMiseLocation Macro
'
Dim honoraires As Workbook
Dim facturation As Worksheet
Dim monFichier As String
monFichier = ThisWorkbook.Path & "[" & ThisWorkbook.Name & "]"
Set honoraires = Workbooks.Open(Filename:="E:EDIRFA
2009HONORAIRES 2009A")
Set facturation = honoraires.Sheets("Facturation")
With facturation
.Range("C16").FormulaR1C1 = "='" & monFichier & "FICHE
LOCATAIRE'!R42C8"
.Range("C18:G18").FormulaR1C1 = "='" & monFichier & "FICHE
LOCATAIRE'!R13C3:R13C6"
.Range("C20:G20").FormulaR1C1 = "='" & monFichier & "FICHE
LOCATAIRE'!R21C3:R21C6"
.Range("C22:G22").FormulaR1C1 = "='" & monFichier & "FICHE
LOCATAIRE'!R29C3:R29C6"
.Range("D25:F25").FormulaR1C1 = "='" & monFichier & "FICHE
LOCATAIRE'!R42C4"
End With
honoraires.Sheets("HONORAIRES DE MISE EN LOCATION").Select
honoraires.Sheets("HONORAIRES DE MISE EN LOCATION").Range
("L12").Select
Set honoraires = Nothing: Set facturation = Nothing
End Sub
Ceci dit, je ne comprend pas trop l'intérêt des formules !!!!
Private Sub CommandButton6_Click() ' ' HonorairesMiseLocation Macro ' Dim honoraires As Workbook Dim facturation As Worksheet Dim monFichier As String
monFichier = ThisWorkbook.Path & "[" & ThisWorkbook.Name & "]" Set honoraires = Workbooks.Open(Filename:="E:EDIRFA 2009HONORAIRES 2009A") Set facturation = honoraires.Sheets("Facturation")
With facturation .Range("C16").FormulaR1C1 = "='" & monFichier & "FICHE LOCATAIRE'!R42C8" .Range("C18:G18").FormulaR1C1 = "='" & monFichier & "FICHE LOCATAIRE'!R13C3:R13C6" .Range("C20:G20").FormulaR1C1 = "='" & monFichier & "FICHE LOCATAIRE'!R21C3:R21C6" .Range("C22:G22").FormulaR1C1 = "='" & monFichier & "FICHE LOCATAIRE'!R29C3:R29C6" .Range("D25:F25").FormulaR1C1 = "='" & monFichier & "FICHE LOCATAIRE'!R42C4" End With honoraires.Sheets("HONORAIRES DE MISE EN LOCATION").Select honoraires.Sheets("HONORAIRES DE MISE EN LOCATION").Range ("L12").Select Set honoraires = Nothing: Set facturation = Nothing End Sub
Ceci dit, je ne comprend pas trop l'intérêt des formules !!!!
Cordialement,
F.
snoopix
FdeCourt a écrit le 20/01/2010 à 13h12 :
Salut,
Essayes avec cette macros
Private Sub CommandButton6_Click() ' ' HonorairesMiseLocation Macro ' Dim honoraires As Workbook Dim facturation As Worksheet Dim monFichier As String
monFichier = ThisWorkbook.Path & "[" & ThisWorkbook.Name & "]" Set honoraires = Workbooks.Open(Filename:="E:EDIRFA 2009HONORAIRES 2009A") Set facturation = honoraires.Sheets("Facturation")
With facturation .Range("C16").FormulaR1C1 = "='" & monFichier & "FICHE LOCATAIRE'!R42C8" .Range("C18:G18").FormulaR1C1 = "='" & monFichier & "FICHE LOCATAIRE'!R13C3:R13C6" .Range("C20:G20").FormulaR1C1 = "='" & monFichier & "FICHE LOCATAIRE'!R21C3:R21C6" .Range("C22:G22").FormulaR1C1 = "='" & monFichier & "FICHE LOCATAIRE'!R29C3:R29C6" .Range("D25:F25").FormulaR1C1 = "='" & monFichier & "FICHE LOCATAIRE'!R42C4" End With honoraires.Sheets("HONORAIRES DE MISE EN LOCATION").Select honoraires.Sheets("HONORAIRES DE MISE EN LOCATION").Range ("L12").Select Set honoraires = Nothing: Set facturation = Nothing End Sub
Ceci dit, je ne comprend pas trop l'intérêt des formules !!!!
Cordialement,
F.
MERCI BEAUCOUP ÇA FONCTIONNE NICKEL !!
FdeCourt a écrit le 20/01/2010 à 13h12 :
Salut,
Essayes avec cette macros
Private Sub CommandButton6_Click()
'
' HonorairesMiseLocation Macro
'
Dim honoraires As Workbook
Dim facturation As Worksheet
Dim monFichier As String
monFichier = ThisWorkbook.Path & "[" & ThisWorkbook.Name
& "]"
Set honoraires = Workbooks.Open(Filename:="E:EDIRFA
2009HONORAIRES 2009A")
Set facturation = honoraires.Sheets("Facturation")
With facturation
.Range("C16").FormulaR1C1 = "='" & monFichier &
"FICHE
LOCATAIRE'!R42C8"
.Range("C18:G18").FormulaR1C1 = "='" & monFichier &
"FICHE
LOCATAIRE'!R13C3:R13C6"
.Range("C20:G20").FormulaR1C1 = "='" & monFichier &
"FICHE
LOCATAIRE'!R21C3:R21C6"
.Range("C22:G22").FormulaR1C1 = "='" & monFichier &
"FICHE
LOCATAIRE'!R29C3:R29C6"
.Range("D25:F25").FormulaR1C1 = "='" & monFichier &
"FICHE
LOCATAIRE'!R42C4"
End With
honoraires.Sheets("HONORAIRES DE MISE EN LOCATION").Select
honoraires.Sheets("HONORAIRES DE MISE EN LOCATION").Range
("L12").Select
Set honoraires = Nothing: Set facturation = Nothing
End Sub
Ceci dit, je ne comprend pas trop l'intérêt des formules !!!!
Private Sub CommandButton6_Click() ' ' HonorairesMiseLocation Macro ' Dim honoraires As Workbook Dim facturation As Worksheet Dim monFichier As String
monFichier = ThisWorkbook.Path & "[" & ThisWorkbook.Name & "]" Set honoraires = Workbooks.Open(Filename:="E:EDIRFA 2009HONORAIRES 2009A") Set facturation = honoraires.Sheets("Facturation")
With facturation .Range("C16").FormulaR1C1 = "='" & monFichier & "FICHE LOCATAIRE'!R42C8" .Range("C18:G18").FormulaR1C1 = "='" & monFichier & "FICHE LOCATAIRE'!R13C3:R13C6" .Range("C20:G20").FormulaR1C1 = "='" & monFichier & "FICHE LOCATAIRE'!R21C3:R21C6" .Range("C22:G22").FormulaR1C1 = "='" & monFichier & "FICHE LOCATAIRE'!R29C3:R29C6" .Range("D25:F25").FormulaR1C1 = "='" & monFichier & "FICHE LOCATAIRE'!R42C4" End With honoraires.Sheets("HONORAIRES DE MISE EN LOCATION").Select honoraires.Sheets("HONORAIRES DE MISE EN LOCATION").Range ("L12").Select Set honoraires = Nothing: Set facturation = Nothing End Sub
Ceci dit, je ne comprend pas trop l'intérêt des formules !!!!