+ Reply to Thread
Results 1 to 4 of 4

Excel VBA Newbie

Hybrid View

  1. #1
    Anauna
    Guest

    Excel VBA Newbie

    Hello,
    I am just learning excel VBA so all suggestions are greatly appreciated.

    Goal...
    User selects a range of cells from the active sheet (any range not "A1:E1"
    as below).
    The selected range is then pasted on the "Red" sheet in the next available
    empty row (no A1 as below).

    I have recorded the macro below with the hope of modifying it to accomplish
    the above. I have stumped myself before getting out of the starting blocks.

    Sub Macro2()

    Range("A1:E1").Select
    Selection.Copy
    Sheets("Red").Select
    Range("A1").Select
    ActiveSheet.Paste
    End Sub
    --
    Thank-you and all suggestions are appreciated.

  2. #2
    Jim Thomlinson
    Guest

    RE: Excel VBA Newbie

    Try this code...

    Public Sub CopyLine()
    Dim wksFrom As Worksheet
    Dim wksTo As Worksheet
    Dim rngFrom As Range

    Set wksFrom = ActiveSheet
    Set rngFrom = wksFrom.Range("A1:E1")
    Set wksTo = Sheets("Red")

    rngFrom.Copy wksTo.Range("A65535").End(xlUp).Offset(1, 0)

    End Sub

    "Anauna" wrote:

    > Hello,
    > I am just learning excel VBA so all suggestions are greatly appreciated.
    >
    > Goal...
    > User selects a range of cells from the active sheet (any range not "A1:E1"
    > as below).
    > The selected range is then pasted on the "Red" sheet in the next available
    > empty row (no A1 as below).
    >
    > I have recorded the macro below with the hope of modifying it to accomplish
    > the above. I have stumped myself before getting out of the starting blocks.
    >
    > Sub Macro2()
    >
    > Range("A1:E1").Select
    > Selection.Copy
    > Sheets("Red").Select
    > Range("A1").Select
    > ActiveSheet.Paste
    > End Sub
    > --
    > Thank-you and all suggestions are appreciated.


  3. #3
    Trevor Shuttleworth
    Guest

    Re: Excel VBA Newbie

    Try:

    Sub Test()
    Selection.Copy
    Sheets("Red").Select
    Range("A65536").End(xlUp).Offset(1,0).Select
    ActiveSheet.Paste
    End Sub

    Regards

    Trevor


    "Anauna" <Anauna@discussions.microsoft.com> wrote in message
    news:52E79575-3221-4879-BCB1-E15124623AE1@microsoft.com...
    > Hello,
    > I am just learning excel VBA so all suggestions are greatly appreciated.
    >
    > Goal...
    > User selects a range of cells from the active sheet (any range not "A1:E1"
    > as below).
    > The selected range is then pasted on the "Red" sheet in the next available
    > empty row (no A1 as below).
    >
    > I have recorded the macro below with the hope of modifying it to
    > accomplish
    > the above. I have stumped myself before getting out of the starting
    > blocks.
    >
    > Sub Macro2()
    >
    > Range("A1:E1").Select
    > Selection.Copy
    > Sheets("Red").Select
    > Range("A1").Select
    > ActiveSheet.Paste
    > End Sub
    > --
    > Thank-you and all suggestions are appreciated.




  4. #4
    JE McGimpsey
    Guest

    Re: Excel VBA Newbie

    One way:

    ActiveSheet.Range("A1:E1").Copy _
    Destination:=Sheets("Red").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)



    Note that selecting or activating is almost never necessary (though
    that's what the macro recorder uses).

    In article <52E79575-3221-4879-BCB1-E15124623AE1@microsoft.com>,
    Anauna <Anauna@discussions.microsoft.com> wrote:

    > Hello,
    > I am just learning excel VBA so all suggestions are greatly appreciated.
    >
    > Goal...
    > User selects a range of cells from the active sheet (any range not "A1:E1"
    > as below).
    > The selected range is then pasted on the "Red" sheet in the next available
    > empty row (no A1 as below).
    >
    > I have recorded the macro below with the hope of modifying it to accomplish
    > the above. I have stumped myself before getting out of the starting blocks.
    >
    > Sub Macro2()
    >
    > Range("A1:E1").Select
    > Selection.Copy
    > Sheets("Red").Select
    > Range("A1").Select
    > ActiveSheet.Paste
    > End Sub


+ 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