+ Reply to Thread
Results 1 to 4 of 4

A simple maco . . .

  1. #1
    Steve
    Guest

    A simple maco . . .

    Would appreciate some help with a simple macro.

    I'd like a keystroke-activated macro to do the following in whatever
    cell I happen to be in:

    insert "text1" into the cell I activate the macro from,

    move one cell to the right and insert "text2",

    select and copy the contents of both cells to the clipboard,

    end the macro with the original cell active and the dashed line around
    both cells indicating they were copied to the clipboard.

    I tried recording the keystrokes to do this, but the recorded macro
    includes specific cell addresses. I need something that uses some form
    of relative cell addressing.

    Thanks.

    Steve

  2. #2
    Bob Phillips
    Guest

    Re: A simple maco . . .

    Hi Steve,

    Sub Macro1()
    With ActiveCell
    .Value = "text1"
    .Offset(0, 1) = "text2"
    .Resize(1, 2).Copy
    End With
    End Sub


    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Steve" <[email protected]> wrote in message
    news:[email protected]...
    > Would appreciate some help with a simple macro.
    >
    > I'd like a keystroke-activated macro to do the following in whatever
    > cell I happen to be in:
    >
    > insert "text1" into the cell I activate the macro from,
    >
    > move one cell to the right and insert "text2",
    >
    > select and copy the contents of both cells to the clipboard,
    >
    > end the macro with the original cell active and the dashed line around
    > both cells indicating they were copied to the clipboard.
    >
    > I tried recording the keystrokes to do this, but the recorded macro
    > includes specific cell addresses. I need something that uses some form
    > of relative cell addressing.
    >
    > Thanks.
    >
    > Steve




  3. #3
    Steve
    Guest

    Re: A simple maco . . .

    Thanks Bob, it works great. I'm just starting to learn about macros,
    appreciate the guidance.

    Steve

    Bob Phillips wrote:

    > Hi Steve,
    >
    > Sub Macro1()
    > With ActiveCell
    > .Value = "text1"
    > .Offset(0, 1) = "text2"
    > .Resize(1, 2).Copy
    > End With
    > End Sub
    >
    >


  4. #4
    JE McGimpsey
    Guest

    Re: A simple maco . . .

    Just an alternative:

    Public Sub Macro2()
    With ActiveCell.Resize(1, 2)
    .Value = Array("text1","text2")
    .Copy
    End With
    End Sub

    In article <[email protected]>,
    "Bob Phillips" <[email protected]> wrote:

    > Sub Macro1()
    > With ActiveCell
    > .Value = "text1"
    > .Offset(0, 1) = "text2"
    > .Resize(1, 2).Copy
    > End With
    > 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