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 :

Saut de cellules


Sujet :

Macros et VBA Excel

  1. #1
    Nouveau Candidat au Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Novembre 2016
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 35
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Novembre 2016
    Messages : 4
    Points : 1
    Points
    1
    Par défaut Saut de cellules
    Bonjour,

    Je suis debutante en VBA et j'aimerais savoir comment faire un saut de cellule après chaque donnée.

    Je m'explique:

    j'ai deux fichiers: ma base et le fichier que je souhaite completer.

    J'aimerai qu'en complétant mon fichier je puisse sauté automatiquement une cellule dans la meme colonne.

    Merci par avance pour votre aide

  2. #2
    Invité
    Invité(e)
    Par défaut
    bonjour,
    aux vue de tes explications, difficile de te proposer autre chose!

    Nom : 2848_marelle1.jpg
Affichages : 343
Taille : 96,2 Ko

  3. #3
    Nouveau Candidat au Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Novembre 2016
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 35
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Novembre 2016
    Messages : 4
    Points : 1
    Points
    1
    Par défaut
    A oui effectivement...

    M'en voulezpas trop je débute encore.

    Ci-joint un exemple de ce que je souhaiterais avoir.

    Je ne peux faire les sauts de ligne manuellement car j'ai près de 3000 cellules...VBA exo.xlsx


    Dites moi si vous arrivez à lire la pièce svp. Dans le cas contraire je la mettrai de nouveau

  4. #4
    Expert éminent sénior

    Profil pro
    Conseil, Formation, Développement - Indépendant
    Inscrit en
    Février 2010
    Messages
    8 456
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Conseil, Formation, Développement - Indépendant

    Informations forums :
    Inscription : Février 2010
    Messages : 8 456
    Points : 16 329
    Points
    16 329
    Par défaut
    Bonjour

    Quand on parle de sauter des lignes je me dis qu'il y a un gros risque de plomber le classeur !

    Ne pas oublier qu'il faut éviter les lignes vides dans Excel sous peine de perdre 90% des automatismes et autres fonctionnalités.

    Ce n'est n'est peut-être pas ce que tu cherches à faire mais tes explications manquant de clarté comme souligné par dysorthographie...

    Edit : ta réponse à croisé la mienne. Quel est l'objectif de ces lignes vides ?
    Chris
    PowerQuery existe depuis plus de 13 ans, est totalement intégré à Excel 2016 &+. Utilisez-le !

    Quand un homme a faim, mieux vaut lui apprendre à pêcher que de lui donner un poisson.
    Confucius

    ----------------------------------------------------------------------------------------------
    En cas de résolution, n'hésitez pas cliquer sur c'est toujours apprécié...

  5. #5
    Nouveau Candidat au Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Novembre 2016
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 35
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Novembre 2016
    Messages : 4
    Points : 1
    Points
    1
    Par défaut
    Le but serait d'alimenter ma colonne B avec une date de début et une date de fin.

    Je dois completer un document official et je ne peux changer la mise en forme.

    Je vous ai mis de nouveau le document avec une information supplémentaire en colonne B

    Concernant les dates de début et de fin je compte les completer par une recherchev

    ...

    VBA exo2.xlsx
    Fichiers attachés Fichiers attachés

  6. #6
    Invité
    Invité(e)
    Par défaut
    Code Testes la Sub test() : 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
    #If VBA7 Then Private Declare PtrSafe Function GlobalUnlock Lib "kernel32" (ByVal hMem As LongPtr) As Long
     Private Declare PtrSafe Function GlobalLock Lib "kernel32" (ByVal hMem As LongPtr) As Long
     Private Declare PtrSafe Function GlobalAlloc Lib "kernel32" (ByVal wFlags As LongPtr, ByVal dwBytes As LongPtr) As Long
     Private Declare PtrSafe Function CloseClipboard Lib "User32" () As Long
     Private Declare PtrSafe Function OpenClipboard Lib "User32" (ByVal hwnd As LongPtr) As Long
     Private Declare PtrSafe Function EmptyClipboard Lib "User32" () As Long
     Private Declare PtrSafe Function lstrcpy Lib "kernel32" (ByVal lpString1 As Any, ByVal lpString2 As Any) As Long
     Private Declare PtrSafe Function SetClipboardData Lib "User32" (ByVal wFormat As LongPtr, ByVal hMem As LongPtr) As Long
     Private Declare PtrSafe Function GetClipboardData Lib "User32" (ByVal wFormat As Long) As Long
    #Else
     Private Declare Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) As Long
     Private Declare Function GlobalLock Lib "kernel32" (ByVal hMem As Long) As Long
     Private Declare Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Long, ByVal dwBytes As Long) As Long
     Private Declare Function CloseClipboard Lib "User32" () As Long
     Private Declare Function OpenClipboard Lib "User32" (ByVal hwnd As Long) As Long
     Private Declare Function EmptyClipboard Lib "User32" () As Long
     Private Declare Function lstrcpy Lib "kernel32" (ByVal lpString1 As Any, ByVal lpString2 As Any) As Long
     Private Declare Function SetClipboardData Lib "User32" (ByVal wFormat As Long, ByVal hMem As Long) As Long
     Private Declare Function GetClipboardData Lib "User32" (ByVal wFormat As Long) As Long
    #End If
    Private Const GHND = &H42
    Private Const CF_TEXT = 1
    Private Const MAXSIZE = 4096
     
    Sub test()
    Sheets("fichier de base").UsedRange.Copy
    txt = ClipBoard_GetData
    txt = Replace("" & txt, vbCrLf, vbCrLf & vbCrLf)
    ClipBoard_SetData "" & txt
    Sheets("Feuil3").Range("A1").PasteSpecial xlPasteAll
    End Sub
     
    Function ClipBoard_GetData() As String
       Dim hClipMemory As Long
       Dim lpClipMemory As Long
       Dim MyString As String
       Dim RetVal As Long
     
       If OpenClipboard(0&) = 0 Then
          MsgBox "Cannot open Clipboard. Another app. may have it open"
          Exit Function
       End If
     
       ' Obtain the handle to the global memory
       ' block that is referencing the text.
       hClipMemory = GetClipboardData(CF_TEXT)
       If IsNull(hClipMemory) Then
          MsgBox "Could not allocate memory"
          GoTo OutOfHere
       End If
     
       ' Lock Clipboard memory so we can reference
       ' the actual data string.
       lpClipMemory = GlobalLock(hClipMemory)
     
       If Not IsNull(lpClipMemory) Then
          MyString = Space$(MAXSIZE)
          RetVal = lstrcpy(MyString, lpClipMemory)
          RetVal = GlobalUnlock(hClipMemory)
     
          ' Peel off the null terminating character.
          MyString = Mid(MyString, 1, InStr(1, MyString, Chr$(0), 0) - 1)
       Else
          MsgBox "Could not lock memory to copy string from."
       End If
     
    OutOfHere:
     
       RetVal = CloseClipboard()
       ClipBoard_GetData = MyString
     
    End Function
    Function ClipBoard_SetData(MyString As String)
       Dim hGlobalMemory As Long, lpGlobalMemory As Long
       Dim hClipMemory As Long, X As Long
     
       ' Allocate moveable global memory.
       '-------------------------------------------
       hGlobalMemory = GlobalAlloc(GHND, Len(MyString) + 1)
     
       ' Lock the block to get a far pointer
       ' to this memory.
       lpGlobalMemory = GlobalLock(hGlobalMemory)
     
       ' Copy the string to this global memory.
       lpGlobalMemory = lstrcpy(lpGlobalMemory, MyString)
     
       ' Unlock the memory.
       If GlobalUnlock(hGlobalMemory) <> 0 Then
          MsgBox "Could not unlock memory location. Copy aborted."
          GoTo OutOfHere2
       End If
     
       ' Open the Clipboard to copy data to.
       If OpenClipboard(0&) = 0 Then
          MsgBox "Could not open the Clipboard. Copy aborted."
          Exit Function
       End If
     
       ' Clear the Clipboard.
       X = EmptyClipboard()
     
       ' Copy the data to the Clipboard.
       hClipMemory = SetClipboardData(CF_TEXT, hGlobalMemory)
     
    OutOfHere2:
     
       If CloseClipboard() = 0 Then
          MsgBox "Could not close Clipboard."
       End If
     
       End Function

  7. #7
    Nouveau Candidat au Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Novembre 2016
    Messages
    4
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 35
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Novembre 2016
    Messages : 4
    Points : 1
    Points
    1
    Par défaut
    Grand merci. Je vais tester ça des ce soir

Discussions similaires

  1. [XL-2007] VBA - Equivalent Wraptext pour saut de cellule
    Par corty69 dans le forum Macros et VBA Excel
    Réponses: 3
    Dernier message: 05/12/2010, 11h18
  2. Saut de cellule parametrable
    Par Le POlonais dans le forum Macros et VBA Excel
    Réponses: 6
    Dernier message: 08/12/2007, 08h59
  3. saut de cellule
    Par fmris dans le forum Macros et VBA Excel
    Réponses: 5
    Dernier message: 08/06/2007, 16h47
  4. [VBA-E] Saut de cellule non demandé
    Par luudii dans le forum Macros et VBA Excel
    Réponses: 4
    Dernier message: 06/04/2007, 16h33
  5. Export vers Excel et saut de ligne dans cellule
    Par sbeu dans le forum API, COM et SDKs
    Réponses: 4
    Dernier message: 16/08/2004, 15h53

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