+ Reply to Thread
Results 1 to 4 of 4

copier sur la prochaine ligne vide

  1. #1

    copier sur la prochaine ligne vide


    Bonjour,

    Voici mon code pr=E9sentement:


    Private Sub Worksheet_Change(ByVal Target As Range)


    If Intersect(Target, Range("A33:Q49")) Is Nothing Then Exit Sub
    If Range("B" & Target.Row) =3D "" Then Exit Sub
    Target.Copy
    Application.EnableEvents =3D False


    taddress =3D Target.Offset(-29, 0).Address


    With Sheets("Rapport des transactions")
    .Range(taddress).PasteSpecial xlPasteAll
    End With


    Application.EnableEvents =3D True


    End Sub


    Au lieu de coller mes donn=E9es au tadress offset(-29,0), j'aimerais que

    les donn=E9es se copie sur la prochaine ligne vide. Donc la premi=E8re
    ligne va se offset de -29 mais apr=E8s les autres vont se mettre
    directemetn sur la prochaine ligne vide.


    Que dois-je faire?=20


    Merci=20
    MP=20


    Reply =BB


  2. #2
    Peter T
    Guest

    Re: copier sur la prochaine ligne vide

    If I understand correctly you want to refer to the first empty cell below
    Target.Offset(-29, 0)

    taddress = Target.Offset(-29, 0).End(xlDown).Offset(1, 0).Address

    In passing I assume Sheets("Rapport des transactions") refers to the
    worksheet module with your code. If so you do not need to qualify the Range
    with the sheet, or for readability use "Me", eg

    Me.Range(taddress).PasteSpecial xlPasteAll

    This avoids hard-coding the sheet name and the risk if it is re-named.

    Ignore the above if you are pasting to a relative position on another sheet.

    Regards,
    Peter T

    <[email protected]> wrote in message
    news:[email protected]...

    Bonjour,

    Voici mon code présentement:


    Private Sub Worksheet_Change(ByVal Target As Range)


    If Intersect(Target, Range("A33:Q49")) Is Nothing Then Exit Sub
    If Range("B" & Target.Row) = "" Then Exit Sub
    Target.Copy
    Application.EnableEvents = False


    taddress = Target.Offset(-29, 0).Address


    With Sheets("Rapport des transactions")
    .Range(taddress).PasteSpecial xlPasteAll
    End With


    Application.EnableEvents = True


    End Sub


    Au lieu de coller mes données au tadress offset(-29,0), j'aimerais que

    les données se copie sur la prochaine ligne vide. Donc la première
    ligne va se offset de -29 mais après les autres vont se mettre
    directemetn sur la prochaine ligne vide.


    Que dois-je faire?


    Merci
    MP


    Reply »



  3. #3

    Re: copier sur la prochaine ligne vide

    ok i change a few thing

    Here is my macro now:

    Private Sub Worksheet_Change(ByVal Target As Range)

    If Intersect(Target, Range("A33:O49")) Is Nothing Then Exit Sub
    If Range("O" & Target.Row) = "" Then Exit Sub
    Target.EntireRow.Copy
    Application.EnableEvents = False

    taddress = (1, Target.Column).End(xlDown).Address

    With Sheets("Rapport des transactions")
    .Range(taddress).PasteSpecial xlPasteAll
    End With

    Application.EnableEvents = True

    End Sub

    I'm trying to copy my info in the first empty row of sheet "Rapport des
    Transactions" in the same column as the target. What should i change
    because it doesn't work?

    Thank you
    MP


  4. #4
    Peter T
    Guest

    Re: copier sur la prochaine ligne vide

    I don't follow, try and explain with examples including addresses for
    selection, range to be copied and the basis for determining the destination.
    Is "Rapport des transactions" same sheet as the Target or another sheet.

    What happens if Target is more than one cell.

    this will never work -
    taddress = (1, Target.Column).End(xlDown).Address

    Did you try the example I posted, maybe you can adapt.

    Regards,
    Peter T


    <[email protected]> wrote in message
    news:[email protected]...
    > ok i change a few thing
    >
    > Here is my macro now:
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > If Intersect(Target, Range("A33:O49")) Is Nothing Then Exit Sub
    > If Range("O" & Target.Row) = "" Then Exit Sub
    > Target.EntireRow.Copy
    > Application.EnableEvents = False
    >
    > taddress = (1, Target.Column).End(xlDown).Address
    >
    > With Sheets("Rapport des transactions")
    > .Range(taddress).PasteSpecial xlPasteAll
    > End With
    >
    > Application.EnableEvents = True
    >
    > End Sub
    >
    > I'm trying to copy my info in the first empty row of sheet "Rapport des
    > Transactions" in the same column as the target. What should i change
    > because it doesn't work?
    >
    > Thank you
    > MP
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1