Repeat Button

Discussion in 'Excel Programming' started by Steved, Oct 22, 2007.

  1. Steved

    Steved Guest

    ursoHello from Steved

    Ok please using the below I want to create a Repeat Button to bev put in the
    excel ribbon ( Using Excel 2007 Version )

    Very simple put if I put the cusor in any cell I want it to copy the Above
    Cell for example I'm in say Cell K202 I want to copy the cell contents off
    Cell K201 and paste the contents into Cell K202

    Sub Repeat()
    Range("H30").Select
    Selection.Copy
    Range("H31").Select
    ActiveSheet.Paste
    End Sub

    Thankyou.
     
    Steved, Oct 22, 2007
    #1
    1. Advertisements

  2. > Ok please using the below I want to create a Repeat Button to bev put in
    > the
    > excel ribbon ( Using Excel 2007 Version )
    >
    > Very simple put if I put the cusor in any cell I want it to copy the Above
    > Cell for example I'm in say Cell K202 I want to copy the cell contents off
    > Cell K201 and paste the contents into Cell K202
    >
    > Sub Repeat()
    > Range("H30").Select
    > Selection.Copy
    > Range("H31").Select
    > ActiveSheet.Paste
    > End Sub


    First off, I would rewrite that subroutine to get rid of all that Selecting,
    Copying and Pasting. Give this a try...

    Sub Repeat()
    If ActiveCell.Row > 1 Then ActiveCell.Value = ActiveCell.Offset(-1, 0)
    End Sub

    Okay, I'm not too familiar with Excel 2007, but a fast look made it seem
    like User Macros can be added quite easily to the Quick Access Toolbar (QAT
    for short). After creating the macro above, right-click the QAT and select
    Customize Quick Access Toolbar. Under the "Choose commands from" drop down,
    select Macros from the list (4th item down on my system), click the name of
    the macro in the list and then click the Add button. Next, click the Modify
    button and choose an icon to your liking. Finally, click OK to return to the
    spreadsheet. Select a cell on the spreadsheet, click your icon that was just
    added to the QAT and the selected cell will be assigned the contents of the
    cell immediately above it.

    Rick
     
    Rick Rothstein \(MVP - VB\), Oct 22, 2007
    #2
    1. Advertisements

  3. Steved

    Steved Guest

    Hello Rick from Steved

    Thankyou very much.

    "Rick Rothstein (MVP - VB)" wrote:

    > > Ok please using the below I want to create a Repeat Button to bev put in
    > > the
    > > excel ribbon ( Using Excel 2007 Version )
    > >
    > > Very simple put if I put the cusor in any cell I want it to copy the Above
    > > Cell for example I'm in say Cell K202 I want to copy the cell contents off
    > > Cell K201 and paste the contents into Cell K202
    > >
    > > Sub Repeat()
    > > Range("H30").Select
    > > Selection.Copy
    > > Range("H31").Select
    > > ActiveSheet.Paste
    > > End Sub

    >
    > First off, I would rewrite that subroutine to get rid of all that Selecting,
    > Copying and Pasting. Give this a try...
    >
    > Sub Repeat()
    > If ActiveCell.Row > 1 Then ActiveCell.Value = ActiveCell.Offset(-1, 0)
    > End Sub
    >
    > Okay, I'm not too familiar with Excel 2007, but a fast look made it seem
    > like User Macros can be added quite easily to the Quick Access Toolbar (QAT
    > for short). After creating the macro above, right-click the QAT and select
    > Customize Quick Access Toolbar. Under the "Choose commands from" drop down,
    > select Macros from the list (4th item down on my system), click the name of
    > the macro in the list and then click the Add button. Next, click the Modify
    > button and choose an icon to your liking. Finally, click OK to return to the
    > spreadsheet. Select a cell on the spreadsheet, click your icon that was just
    > added to the QAT and the selected cell will be assigned the contents of the
    > cell immediately above it.
    >
    > Rick
    >
    >
     
    Steved, Oct 22, 2007
    #3
  4. Steved

    uchiha Guest

    Steved wrote on 10/22/2007 16:36 ET
    > ursoHello from Steve
    >
    > Ok please using the below I want to create a Repeat Button to bev put in th
    > excel ribbon ( Using Excel 2007 Version
    >
    > Very simple put if I put the cusor in any cell I want it to copy the Abov
    > Cell for example I'm in say Cell K202 I want to copy the cell contents of
    > Cell K201 and paste the contents into Cell K20
    >
    > Sub Repeat(
    > Range("H30").Selec
    > Selection.Cop
    > Range("H31").Selec
    > ActiveSheet.Past
    > End Su
    >
    > Thankyou
    >

    It is very rare for me to see questions towards repeat button. This is a goo
    question

    Actually repeat button is not frequently used among all the button controls

    http://www.kettic.com/winforms_ui/buttons_overview.shtm

    Here I found some detailed materials about the repeat button, hope it can b
    useful to your situation

    http://www.kettic.com/winforms_ui/csharp_guide/buttons_repeatbutton.shtml
     
    uchiha, Apr 22, 2014
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.