+ Reply to Thread
Results 1 to 4 of 4

help with VB/Macro to shift cells

  1. #1

    help with VB/Macro to shift cells

    Hello -
    I have a basic spreadsheet with the following information. Cells
    A2:A11 contain basic number valus. Cell A1 is blank.

    What I would like to accomplish is for a user to enter a value into
    cell A1 and have that information replace the value in A2 and shift the
    rest of the values in the column down. I only want to store 10 numbers
    (ie A2:A11) at a time.

    Can anyone provide me with the knowledge on how to accomplish this?

    Thanks!


  2. #2
    Bob Phillips
    Guest

    Re: help with VB/Macro to shift cells

    '-----------------------------------------------------------------
    Private Sub Worksheet_Change(ByVal Target As Range)
    '-----------------------------------------------------------------
    Const WS_RANGE As String = "A1"

    On Error GoTo ws_exit:
    Application.EnableEvents = False
    If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
    Range("A2:A10").Copy Range("A3:A11")
    Range("A2").Value = Target.Value
    End If

    ws_exit:
    Application.EnableEvents = True
    End Sub

    'This is worksheet event code, which means that it needs to be
    'placed in the appropriate worksheet code module, not a standard
    'code module. To do this, right-click on the sheet tab, select
    'the View Code option from the menu, and paste the code in.




    --
    HTH

    Bob Phillips

    (remove xxx from email address if mailing direct)

    <[email protected]> wrote in message
    news:[email protected]...
    > Hello -
    > I have a basic spreadsheet with the following information. Cells
    > A2:A11 contain basic number valus. Cell A1 is blank.
    >
    > What I would like to accomplish is for a user to enter a value into
    > cell A1 and have that information replace the value in A2 and shift the
    > rest of the values in the column down. I only want to store 10 numbers
    > (ie A2:A11) at a time.
    >
    > Can anyone provide me with the knowledge on how to accomplish this?
    >
    > Thanks!
    >




  3. #3
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Response

    Dan

    Try the attached.

    It's a short macro linked to the worksheet change event.
    Attached Files Attached Files

  4. #4
    dan
    Guest

    Re: help with VB/Macro to shift cells

    This is perfect! Thanks so much.


+ 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