How to improve my current method of inputting a date into a cell using VBA

fray85

New Member
Joined
May 28, 2014
Messages
2
Hi all,I was hoping someone could help me improve my script of adding a date to a cell (limited to 2 columns). I have created a custom form for data input.1. The form monitors vehicle deliveries from a start location to an end location. 2. When a job starts, the user should be able to double click on the cell and it populates using Now (current date and time). 3. They should only be allowed to do this once for the cell (but I have not quite figured that part out yet). 4. The whole spreadsheet is locked. The only way to update those cells in a particular column is by either initially entering it in the custom form (which they can do once only), or by double clicking the cell.This is the script I am using:Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)Dim MyRange As RangeDim IntersectRange As RangeSet MyRange = Range("K1:L3000")Set IntersectRange = Intersect(Target, MyRange)If IntersectRange Is Nothing ThenExit SubElseActiveSheet.Unprotect Password:="pip15"Application.ScreenUpdating = FalseTarget = Format(Now)ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=TrueActiveSheet.EnableSelection = xllockedCellsEnd IfEnd SubThe main problem I am facing is that is takes quite some time to open the file when using this script, and then when the user double clicks, it take a few seconds to populate the cell. Please can you propose a better method (bearing in mind I am quite new to programming and VBA) Many thanks for any support re. this.Fray
 
Last edited:

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Why does this keep coming in on one line?I intersted "
" on every line and it looked fine in preview mode.
 
Upvote 0

Forum statistics

Threads
1,215,467
Messages
6,124,984
Members
449,201
Latest member
Lunzwe73

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top