IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Macros et VBA Excel Discussion :

Assigner une variable comme étant la première case vide d'une colonne


Sujet :

Macros et VBA Excel

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Femme Profil pro
    Ingénieur
    Inscrit en
    Novembre 2019
    Messages
    23
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Ingénieur

    Informations forums :
    Inscription : Novembre 2019
    Messages : 23
    Par défaut Assigner une variable comme étant la première case vide d'une colonne
    Bonjour à tous,

    Voici le code effectué ce jour :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    Sub IMPORTATION()
     
    Application.DisplayAlerts = False
     
    Dim fichier As String, chemin As String
    Dim FichierPageFinale As String
     
    Dim Repertoire As FileDialog
    Dim Table As Variant
     
    Dim wkA As Workbook, wkB As Workbook
    Dim j As Long
     
        Set Repertoire = Application.FileDialog(msoFileDialogFolderPicker)
        Repertoire.Title = ("Choisir le r?pertoire")
        Repertoire.Show
     
     
        chemin = Repertoire.SelectedItems(1)
        chemin = chemin & "\"
        fichier = Dir(chemin & "*.xlsm")
     
     
        Application.ScreenUpdating = False
        Application.DisplayAlerts = False
        Application.Cursor = xlWait
        Application.StatusBar = "                         TRAITEMENT EN COURS                         TRAITEMENT EN COURS                         TRAITEMENT EN COURS                         TRAITEMENT EN COURS                         TRAITEMENT EN COURS"
     
     
        'On r?cup?re les informations sur le fichier
        fichierSynthese = ActiveWorkbook.Name
     
        j = 2
     
        Do While fichier <> ""
        Set Wb = Workbooks.Open(Filename:=chemin & fichier, Format:=5)
        DoEvents
     
     
            Workbooks(fichierSynthese).Worksheets("SUIVI ACTIONS").Cells(j, 2) = Wb.Worksheets("Contexte").Range("F2")
            Workbooks(fichierSynthese).Worksheets("SUIVI ACTIONS").Cells(j, 9) = Wb.Worksheets("Contexte").Range("O2")
            Workbooks(fichierSynthese).Worksheets("SUIVI ACTIONS").Cells(j, 13) = Wb.Worksheets("Contexte").Range("I5")
            Workbooks(fichierSynthese).Worksheets("SUIVI ACTIONS").Cells(j, 15) = Wb.Worksheets("Contexte").Range("H12")
            Workbooks(fichierSynthese).Worksheets("SUIVI ACTIONS").Cells(j, 16) = Wb.Worksheets("Contexte").Range("E12")
            Workbooks(fichierSynthese).Worksheets("SUIVI ACTIONS").Cells(j, 19) = Wb.Worksheets("Contexte").Range("D19")
            Workbooks(fichierSynthese).Worksheets("SUIVI ACTIONS").Cells(j, 30) = Wb.Worksheets("Contexte").Range("C18")
            Workbooks(fichierSynthese).Worksheets("SUIVI ACTIONS").Cells(j, 31) = Wb.Worksheets("Contexte").Range("H18")
     
            j = j + 1
     
     
        Wb.Close savechanges:=False
        DoEvents
        Set Wb = Nothing
        fichier = Dir
        Loop
     
        Application.ScreenUpdating = True
        Application.DisplayAlerts = True
        Application.Cursor = xlDefault
        Application.StatusBar = False
     
        Columns("G:G").Select
        Selection.NumberFormat = "m/d/yyyy"
        Columns("I:I").Select
        Selection.NumberFormat = "#,##0.00 $"
        Selection.NumberFormat = "#,##0.0 $"
        Selection.NumberFormat = "#,##0 $"
        Columns("K:K").Select
        Selection.NumberFormat = "m/d/yyyy"
     
    Application.DisplayAlerts = True
     
    End Sub
    J'aurais besoin que ma variable " j " soit définie non pas égale à 2 mais comme étant la première ligne en face de la première case vide de la colonne B...

    Sauriez-vous m'aider ?

    Merci
    Ju

  2. #2
    Expert confirmé
    Homme Profil pro
    Electrotechnicien
    Inscrit en
    Juillet 2016
    Messages
    3 241
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 71
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Electrotechnicien

    Informations forums :
    Inscription : Juillet 2016
    Messages : 3 241
    Par défaut
    Bonjour,

    Essayez ceci
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    j = [B1].End(xlDown).Row + 1
    Cdlt

  3. #3
    Membre averti
    Femme Profil pro
    Ingénieur
    Inscrit en
    Novembre 2019
    Messages
    23
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Ingénieur

    Informations forums :
    Inscription : Novembre 2019
    Messages : 23
    Par défaut
    Merci !

Discussions similaires

  1. Réponses: 4
    Dernier message: 10/10/2010, 23h06
  2. [FTP] Définir une variable en tant que constante
    Par Anduriel dans le forum Langage
    Réponses: 2
    Dernier message: 15/01/2006, 11h39
  3. donner la valeur d'une variable comme nom de table
    Par cladsam dans le forum MS SQL Server
    Réponses: 1
    Dernier message: 14/10/2005, 15h16
  4. [Custom Tags 1.2] Passer une variable comme valeur d'attribut d'un tag jsp
    Par Pi2 dans le forum Taglibs
    Réponses: 7
    Dernier message: 16/09/2005, 14h44
  5. [curseurs] utiliser une variable comme nom de champ
    Par Christian31 dans le forum MS SQL Server
    Réponses: 2
    Dernier message: 09/09/2005, 14h12

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo