Hi,
My situation is that I’ve trying for days now to find VBA code that will insert time stamp into a specified range of cells and if the user Double Clicks the cell again it will remove the time stamp. Each time a new daily exported.csv opens
The reason is that the users receive daily a newly created exported.csv file, so I need the VBA to be called/running from the users Personal.xlsb.
Now, I know that I could use the keyboard shorts cut, but believe it or not some of my users will never remember this method. So I need a method to do this using VBA, (the vba needs to be able to run from …\XLSTART\ personal.xlsb only if the new export.csv s worksheet name is named “ Whatever-Exports” .
After trawling the big “www”, I have found heaps of examples on how to insert the time stamp into a range of cells but they all use the Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) event .
Which will never be normally available to the new daily exported.csv.
So this is where I am having the difficulty as I don’t know how to call the Worksheet_BeforeDoubleClick when a new workbook is opened as it seems, even when the VBA is residing within the users “ personal.xlsb”
I finally found this sample:
http://stackoverflow.com/questions/1...ate-workbook-t
I am sure this'll work, but after reading a few times, and a few attempts, I just can’t get my head around the instructions to suit it my needs.
So my Question is, is this achievable? and is there a more simple way and if so how?
Any help in simple (laymans terms) would be great , thanks in advance
VBA Code below is what I am attempting to get to run from any new workbook/sheet with a specific name
Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim MyRange As Range
Dim IntersectRange As Range
Dim EndRow As Long
Dim TheWorksheetname As String
TheWorksheetname = ActiveSheet.Name
‘Application.ScreenUpdating = False
If TheWorksheetname = "ExportedWork_Sheet1" Then
EndRow = Range("D" & Rows.Count).End(xlUp).Row
Set MyRange = Range("G2:J" & EndRow) 'last row
Set IntersectRange = Intersect(Target, MyRange)
On Error GoTo SkipIt
If IntersectRange Is Nothing Then
Exit Sub
Else
Target = Format(Now, "ttttt") ’still to find a way to format to lose the secs or …=(left(A1,5)
'Application.ScreenUpdating = True
End If
ActiveCell.Offset(, 1).Select ‘ move curser away from cell
SkipIt:
Exit Sub
Else
'MsgBox "File does not exist"
exit sub
End If
End Sub