Hello everyone,
I have this macro that automatically inserts the date in column B when data is entered in column D. What I would like to is when I press enter in a cell in column D then the selection cell will move to column E and then when I enter again in column E then move to column D again on the next row.
IE. if I'm in D12 and press enter then move to E12 and then move to D13 and so on.
Thanks for all your help,
Alex
Code:Private Sub Worksheet_Change(ByVal Target As Range) If Target.Cells.Count > 1 Then Exit Sub If Not Intersect(Target, Range("D5:D400")) Is Nothing Then With Target(1, -1) .Value = Now .EntireColumn.AutoFit End With End If End Sub
Last edited by Alexander Ceed; 01-28-2010 at 06:54 AM.
Hello Alex,
The easiest way is to protect the worksheet and unlock the cells that will be used for entering the data.
Sincerely,
Leith Ross
Remember To Do the Following....
1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.2. Thank those who have helped you by clicking the Starbelow the post.
3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
Thanks for the suggestion. I did as you said Ross and now it just goes through the cells that are unlocked but the problem is that I need to keep the column B unlocked for the vba to work and I don't want to be able to select any cell in that column.
How about adding
somewhere at the beginning of the code and then changing it back toCode:Application.MoveAfterReturnDirection = xlToRight
before the workbook is closed.Code:Application.MoveAfterReturnDirection = xlDown
With regards to this:
You can use something likethe problem is that I need to keep the column B unlocked for the vba to work
to protect the sheet from user input but still enable VBA access to locked cells. Then Leith's suggestion might be the easiest way to go.Code:ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, UserInterfaceOnly:=True
Last edited by teylyn; 01-28-2010 at 06:29 AM.
teylyn
Microsoft MVP - Excel
At Excelforum, you can say "Thank you!" by clicking theicon below the post.
Avoid pie charts with more than two data points. Why? See here (pdf, 559 kb). The only acceptable pie chart is here.
Thanks Teylyn and you too Ross. This is all that I needed and it works like a charm now.
It wasn't about protecting the cells but I needed a way to jump only in the cells that needed editing. Saves time as well. Thanks again you guys and I'll add some points to your reputation status.Code:ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, UserInterfaceOnly:=True
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks