help with VB/Macro to shift cells

  • Thread starter Thread starter dan.gates
  • Start date Start date
D

dan.gates

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!
 
'-----------------------------------------------------------------
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)
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top