This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
' Summary: Returns a friendly timestamp like "Just now" or "45 minutes ago" | |
' Param cell: The cell used for the function. | |
' Should only be a single cell and should be a date with or without time. | |
Public Function HowLongAgo(ByRef cell As Range) As String | |
' Only allow dates and only allow single cells | |
If ((Not IsDate(cell)) Or cell.Cells.Count > 1) Then | |
HowLongAgo = vbNullString | |
Exit Function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
Private Sub Worksheet_Change(ByVal target As Range) | |
Dim sh As Worksheet | |
Set sh = ActiveSheet | |
Dim newdata As Range | |
Set newdata = Application.Intersect(target, sh.Range("A2", "A" & sh.Rows.Count)) | |
If (Not newdata Is Nothing) Then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
Public CopyNewDataRange As Range | |
Public Sub CopyNewData() | |
Dim copyFrom As Range | |
Dim copyTo As Range | |
Set copyFrom = Sheets("Sheet1").Range("A2") | |
Set copyTo = Sheets("Sheet2").Range("A2") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
Private Sub Worksheet_Change(ByVal target As Range) | |
Dim sh As Worksheet | |
Set sh = ActiveSheet | |
Dim newdata As Range | |
Set newdata = Application.Intersect(target, sh.Range("A2", "A" & sh.Rows.Count)) | |
If (Not newdata Is Nothing) Then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
Public Sub CopyNewData() | |
Dim copyFrom As Range | |
Dim copyTo As Range | |
Set copyFrom = Sheets("Sheet1").Range("A2") | |
Set copyTo = Sheets("Sheet2").Range("A2") | |
copyFrom.Copy copyTo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
Public Sub WriteHello() | |
Dim cell As Range | |
Set cell = Selection | |
cell.Value = "Hello, cell!" | |
End Sub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
Public Sub DoWork() | |
Call PrintNumber | |
End Sub | |
Private Sub PrintNumber(Optional ByRef number As Variant) | |
If (IsMissing(number)) Then | |
Debug.Print "number was not passed" | |
Else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
Public Sub DoWork() | |
Call PrintNumber | |
End Sub | |
Private Sub PrintNumber(Optional ByVal number As Long = 10) | |
Debug.Print number | |
End Sub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
Public Sub DoWork() | |
Call PrintNumber | |
End Sub | |
Private Sub PrintNumber(Optional ByVal number As Long) | |
Debug.Print number | |
End Sub |
NewerOlder