Hi all, I am currently stuck on finding a way to input all new changes made to a specific row of cells into a string so that I can parse the final string into another function that drafts out an Outlook message. As there will be continuous updates made to the row, I want to be able to "write" each change made, in the form of a string, and append this string to a template string variable called "gTemp" constantly until a button has been clicked which will end the append action and call on the other function.
The changes made in the row are variables in a Date and Number format.
The logical steps can be broken down as follows:
I greatly appreciate any help on this!
The changes made in the row are variables in a Date and Number format.
The logical steps can be broken down as follows:
- Checks for updates on Row
- Writes the Date and Number into a string
- Append the string to the variable "gTemp"
- Repeat Steps 1 - 3
- When button is clicked, the other function is called upon and the variable "gTemp" in the form of a String is parsed into it
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim s, gTemp As String
Dim xRg_A, xRg_B, xRg_C, xRg_D As Range
gTemp = "Hi all," & vbNewLine & vbNewLine & "The required OT support can be found below."
On Error Resume Next
If Target.Cells.Count > 1 Then Exit Sub
Set xRg_A = Intersect(Rows("58"), Target)
Set xRg_B = Intersect(Rows("125"), Target)
Set xRg_C = Intersect(Rows("192"), Target)
Set xRg_D = Intersect(Rows("259"), Target)
If xRg_A Is Nothing And xRg_B Is Nothing And xRg_C Is Nothing And xRg_D Is Nothing Then Exit Sub 'checks for updates in rows
If IsNumeric(Target) = False Then Exit Sub 'exits the function if value input is not in a numeric form
If xRg_A Is Nothing Then 'determines which shift requires OT
If xRg_B Is Nothing Then
If xRg_C Is Nothing Then
s = "D"
Else
s = "C"
End If
Else
s = "B"
End If
Else
s = "A"
End If
gTemp = gTemp & vbNewLine & vbNewLine & "Shift " & s & " has " & Target & " OT required on " & Target.EntireColumn.Cells(2).Value & "."
Call 'other function here
End Sub
I greatly appreciate any help on this!