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 :

problème de select dans code [XL-2010]


Sujet :

Macros et VBA Excel

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé Avatar de grisan29
    Homme Profil pro
    ouvrier poseur
    Inscrit en
    Octobre 2006
    Messages
    866
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : ouvrier poseur
    Secteur : Bâtiment

    Informations forums :
    Inscription : Octobre 2006
    Messages : 866
    Par défaut problème de select dans code
    bonjour a vous tous

    j'ai récupéré un fichier sur le net qui est plein de lignes remplie de .select qui me pose a quelques endroits des soucis de suppression donc dans le bloc de code suivant
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    Sheets("Feuil2").Select
    Range(AdrDebut).Offset(0, 0).Select
    Selection = "Reference"
    With Selection
        .ColumnWidth = 11
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlCenter
        With .Font
            .Size = 10
        End With
    End With
    j'arrive a modifier la première ligne par
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    With Sheets("Feuil2")
    .Range(AdrDebut).Offset(0, 0)= "Reference"
    mais pour l'autre sélection je ne sais pas par quoi la remplacer

    Merci de votre aide, car il y a plein de lignes de codes comme celle la

    Pascal

  2. #2
    Membre averti
    Homme Profil pro
    Ingénieur Financier
    Inscrit en
    Mai 2012
    Messages
    58
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Ingénieur Financier
    Secteur : Finance

    Informations forums :
    Inscription : Mai 2012
    Messages : 58
    Par défaut
    Salut,

    essaye ça:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    Sheets("Feuil2").Activate
    Range(AdrDebut).Offset(0, 0).Select
     
    With Selection
        .Value = "Reference"
        .ColumnWidth = 11
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlCenter
        With .Font
            .Size = 10
        End With
    End With

  3. #3
    Membre Expert Avatar de rvtoulon
    Homme Profil pro
    Agent Technique
    Inscrit en
    Mars 2009
    Messages
    1 042
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Agent Technique
    Secteur : Santé

    Informations forums :
    Inscription : Mars 2009
    Messages : 1 042
    Par défaut
    bonjour et comme çà :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    With Sheets("Feuil2").Range(AdrDebut)
    .Value = "Reference"
    .ColumnWidth = 11
    .HorizontalAlignment = xlCenter
    .VerticalAlignment = xlCenter
    .Font.Size = 10
     
    End With
    pour moi offset(0,0) sert à rien

  4. #4
    Membre averti
    Homme Profil pro
    Ingénieur Financier
    Inscrit en
    Mai 2012
    Messages
    58
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Ingénieur Financier
    Secteur : Finance

    Informations forums :
    Inscription : Mai 2012
    Messages : 58
    Par défaut
    en effet la version de rvtoulon est bien meilleure!

  5. #5
    Membre Expert Avatar de rvtoulon
    Homme Profil pro
    Agent Technique
    Inscrit en
    Mars 2009
    Messages
    1 042
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Agent Technique
    Secteur : Santé

    Informations forums :
    Inscription : Mars 2009
    Messages : 1 042
    Par défaut
    Merci amrod.

  6. #6
    Membre éclairé Avatar de grisan29
    Homme Profil pro
    ouvrier poseur
    Inscrit en
    Octobre 2006
    Messages
    866
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : ouvrier poseur
    Secteur : Bâtiment

    Informations forums :
    Inscription : Octobre 2006
    Messages : 866
    Par défaut
    bonjour a vous

    merci de vos réponses mais l'offset que j'ai donné est erroné et est peut etre utile, je vous joints tout le code pour vous en rendre compte et vous verrez s'il peux etre améliorer
    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
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    Sub Gabarit_Bibli(NbBibli, Devise)
    Dim AdrDebut$, Na%, i%
    Dim Toto$, Classeur$
    Dim CX As Variant
     
    Application.ScreenUpdating = False
    Na = 30000 'Capacité de la Bibli (ici 1000 articles, max=30000)
    Classeur = Workbooks(1).Name
    Workbooks(Classeur).Worksheets("Feuil2").Activate
     
    '---------------------- Adressage pour 28 bibli ----------------------------------
    AdrDebut = Range("A1").Address
    CX = Array("", "A1", "J1", "S1", "AB1", "AK1", "AT1", "BC1", _
                "BL1", "BU1", "CD1", "CM1", "CV1", "DE1", "DN1", _
                "DW1", "EF1", "EO1", "EX1", "FG1", "FP1", "FY1", _
                "GH1", "GQ1", "GZ1", "HI1", "HR1", "IA1", "IJ1")
     
    For i = 1 To NbBibli
    '--------------- Adressage des Biblis --------------
        AdrDebut = Range(CX(i)).Address
        Range(AdrDebut).Offset(0, 1).Select
    '----------------- Titre --------------------------
        With Selection
            .ColumnWidth = 56.43
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlCenter
            With Selection.Font
                .Size = 10
                .Bold = True
            End With
        End With
    '----------------- Référence -------------------
        Range(AdrDebut).Offset(1, 0).Select
        Selection = "Reference"
        With Selection
            .ColumnWidth = 11
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlCenter
            With .Font
                .Size = 10
            End With
        End With
    '********* Colonne Réference **************
        Range(AdrDebut).Offset(2, 0).Select
        ActiveCell.Range(Cells(1, 1), Cells(Na, 1)).Select
        With Selection
            .HorizontalAlignment = xlCenter
        End With
    '----------------- Désignation -------------------
        Range(AdrDebut).Offset(1, 1).Select
        Selection = "Désignation"
        With Selection
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlCenter
            With .Font
                .Size = 10
            End With
        End With
    '********** Colonne Désignation *************
        Range(AdrDebut).Offset(2, 1).Select
        ActiveCell.Range(Cells(1, 1), Cells(Na, 1)).Select
        With Selection
            .HorizontalAlignment = xlLeft
        End With
    '------------------ Unité ------------------------
        Range(AdrDebut).Offset(1, 2).Select
        Selection = "Unité"
        With Selection
            .ColumnWidth = 5
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlCenter
        End With
    '********** Colonne Unité ***************
        Range(AdrDebut).Offset(2, 2).Select
        ActiveCell.Range(Cells(1, 1), Cells(Na, 1)).Select
        With Selection
            .HorizontalAlignment = xlCenter
        End With
    '------------------ Prix Unitaire HTVA (devise) ------------
        Range(AdrDebut).Offset(1, 3).Select
        Selection = "Prix Unit. (" & Devise & ")"
        With Selection
            .ColumnWidth = 9.29
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlCenter
            With .Font
                .Size = 8
            End With
        End With
    '************ Colonne Prix Unitaire ************
        Range(AdrDebut).Offset(2, 3).Select
        ActiveCell.Range(Cells(1, 1), Cells(Na, 1)).Select
        With Selection
            .HorizontalAlignment = xlRight
        End With
    '-----------------------------------------------
    '---------------- Libre 1 ----------------------
        Range(AdrDebut).Offset(1, 4).Select
        Selection = " Stock "
        With Selection
            .ColumnWidth = 5
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlCenter
            With .Font
                .Size = 8
            End With
        End With
    '<<<<<<<<<< Colonne Libre 1 >>>>>>>>>>>>>>>>>
        Range(AdrDebut).Offset(2, 4).Select
        ActiveCell.Range(Cells(1, 1), Cells(Na, 1)).Select
        With Selection
            .HorizontalAlignment = xlRight
        End With
    '-----------------------------------------------
    '---------------- Libre 2 ----------------------
        Range(AdrDebut).Offset(1, 5).Select
        Selection = "Seuil"
        With Selection
            .ColumnWidth = 5
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlCenter
            With .Font
                .Size = 8
            End With
        End With
    '<<<<<<<<<< Colonne Libre 2 >>>>>>>>>>>>>>>>>
        Range(AdrDebut).Offset(2, 5).Select
        ActiveCell.Range(Cells(1, 1), Cells(Na, 1)).Select
        With Selection
            .HorizontalAlignment = xlRight
        End With
    '-----------------------------------------------
    '---------------- Libre 3 ----------------------
        Range(AdrDebut).Offset(1, 6).Select
        Selection = "Prix en Stock"
        With Selection
            .ColumnWidth = 11
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlCenter
            With .Font
                .Size = 8
            End With
        End With
    '<<<<<<<<<< Colonne Libre 3 >>>>>>>>>>>>>>>>>
        Range(AdrDebut).Offset(2, 6).Select
        ActiveCell.Range(Cells(1, 1), Cells(Na, 1)).Select
        With Selection
            .HorizontalAlignment = xlRight
        End With
    '--------------------------------------------
    Application.ScreenUpdating = True
    End Sub
    Pascal

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Problème de selected dans un listbox
    Par delichoc dans le forum ASP
    Réponses: 4
    Dernier message: 21/06/2008, 21h06
  2. Problème de synthaxe dans code SAS
    Par CélineM dans le forum SAS Base
    Réponses: 1
    Dernier message: 07/05/2008, 10h08
  3. Problème avec assembleur dans code C++
    Par wishmerhill dans le forum C++
    Réponses: 0
    Dernier message: 05/03/2008, 11h38
  4. Problème avec Select dans le formulaire
    Par jejefm dans le forum Langage
    Réponses: 2
    Dernier message: 24/04/2007, 09h34
  5. Réponses: 1
    Dernier message: 20/07/2006, 17h03

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