+ Reply to Thread
Results 1 to 8 of 8

Using one cell to enter data and move pervious data over

  1. #1
    Registered User
    Join Date
    06-07-2008
    Posts
    14

    Using one cell to enter data and move pervious data over

    I want to use only one cell to enter data. Once I enter data a second time in the same cell I want the old data to move to the next cell on the right.

    Example: I enter 3/12 in colum A cell 1. I click the enter button now it moves 3/12 to column b cell 1. Now I enter 3/19 in column A cell 1 click enter. Now 3/19 goes to column B cell1 and 3/12 moves to column C cell 1.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello jalicea,

    Welcome to the Forum!

    Here is macro that will shift the cells for you after you input a value. The cell I used to test the macro was $A$4, but you can change this before you save the macro to the cell you are using.
    Please Login or Register  to view this content.
    How to Save a Worksheet Event Macro
    1. Copy the macro using CTRL+C keys.
    2. Open your Workbook and Right Click on the Worksheet's Name Tab for the Worksheet the macro will run on.
    3. Left Click on View Code in the pop up menu.
    4. Paste the macro code using CTRL+V
    5. Save the macro in your Workbook using CTRL+S

    Sincerely,
    Leith Ross

  3. #3
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967
    Paste the following code into the approriate sheet tab in the VBA editor (Alt F11).

    Please Login or Register  to view this content.
    It stores a copy of the value of A1 in A4. This can of course be changed to any cell in rows 2 onwards, maybe one out of sight.
    Martin

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Martin,

    Whenever writing code for the Worksheet_Change() or Worksheet_SelectionChange() event, it is good idea to use Application.EnableEvents = False before you change the value of a cell in the macro. The act of changing a cell's value while in the event sequence will invoke the event again. This will continue under the stack overflows and VBA errors out. Remember to re-enable events by using Application.EnableEvents = True prior to exiting the event at any time.

    Sincerely,
    Leith Ross

  5. #5
    Registered User
    Join Date
    06-07-2008
    Posts
    14

    ???I Keep trying???

    Quote Originally Posted by Leith Ross
    Hello jalicea,

    Welcome to the Forum!

    Here is macro that will shift the cells for you after you input a value. The cell I used to test the macro was $A$4, but you can change this before you save the macro to the cell you are using.
    Please Login or Register  to view this content.
    How to Save a Worksheet Event Macro
    1. Copy the macro using CTRL+C keys.
    2. Open your Workbook and Right Click on the Worksheet's Name Tab for the Worksheet the macro will run on.
    3. Left Click on View Code in the pop up menu.
    4. Paste the macro code using CTRL+V
    5. Save the macro in your Workbook using CTRL+S

    Sincerely,
    Leith Ross
    While I can transfer the code over it is not performing.

  6. #6
    Registered User
    Join Date
    06-07-2008
    Posts
    14

    Unhappy ???I Keep trying???

    I have copied and save the cell is not moving the data over. What I am trying to acomplish is I have several employees and I want to enter the date they work overtime. Then I want to know know many times thay worked overtime. So what I am looking for is:

    If I pick column B cell 1 to be where I enter the date they worked overtime and hit enter I want it to move it over to column C cell 1. I want column B cell 1 to be the only place I enter the date. Then they work overtime again I want to enter the date in column B cell 1 what I entered earlier goes to column D cell 1 and the new date goes to column C cell 1. Then I want column A cell 1 to count every time I enter a date in column B cell 1. I need to keep a record of everytime thay work overtime just entering it in one cell but keeping a total and record.

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello jalicea,

    I updated the macro to add the count to cell A1.
    Please Login or Register  to view this content.
    How to Save a Worksheet Event Macro
    1. Copy the macro using CTRL+C keys.
    2. Open your Workbook and Right Click on the Worksheet's Name Tab for the Worksheet the macro will run on.
    3. Left Click on View Code in the pop up menu.
    4. Paste the macro code using CTRL+V
    5. Save the macro in your Workbook using CTRL+S

    Sincerely,
    Leith Ross

  8. #8
    Registered User
    Join Date
    06-07-2008
    Posts
    14

    Micro Multiple Date and Employee Count

    I figure out the fisrt micro. what if I got 10 employees and I put them in order as emplyee 1 in A1, employee 2 in A2, employee 3 in A3 and so on. Now the micro is in B1 for employee 1 to enter date and in B2 for employee 2 to enter date. How can this be worked out?

    Private Sub Worksheet_Change(ByVal Target As Range)

    If Target.Address = "$A$4" Then
    If Not IsEmpty(Target) Then
    Application.EnableEvents = False
    Target.Insert Shift:=xlShiftToRight, CopyOrigin:=Target
    Application.EnableEvents = True
    End If
    End If

    End Sub
    Last edited by jalicea; 06-28-2008 at 10:50 AM.

+ 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