Hi,
I have been working with an Excel file to send automatic mail based on some criteria and change dates when the ActiveX check box is checked.
Condition:
If I check the box, 'TRUE' is displayed in the adjacent cell. If TRUE, the current date has to be added with numbers (7, 30, 120,..; weekly, monthly, quarterly..) and the new date is displayed in a cell in the same row. The new date is then copied to the current date and the checkbox has to be unchecked automatically. if FALSE, the current date has to be displayed as the new date (either Copy+Paste or no change at all).
Problem:
I am almost successful with my code but still have a small Problem with the For and If statements. The code as displayed below contains also the commented statements which I used for this purpose. But the problem is that regardless of whether the checkbox is checked, all the Dates in the new date column changes automatically. I am trying alternatives myself. If anyone could provide me a solution sooner, it is much appreciated.
The sample document can be found here.
Thanks a lot!
Cheers,
Bharath
I have been working with an Excel file to send automatic mail based on some criteria and change dates when the ActiveX check box is checked.
Condition:
If I check the box, 'TRUE' is displayed in the adjacent cell. If TRUE, the current date has to be added with numbers (7, 30, 120,..; weekly, monthly, quarterly..) and the new date is displayed in a cell in the same row. The new date is then copied to the current date and the checkbox has to be unchecked automatically. if FALSE, the current date has to be displayed as the new date (either Copy+Paste or no change at all).
Problem:
I am almost successful with my code but still have a small Problem with the For and If statements. The code as displayed below contains also the commented statements which I used for this purpose. But the problem is that regardless of whether the checkbox is checked, all the Dates in the new date column changes automatically. I am trying alternatives myself. If anyone could provide me a solution sooner, it is much appreciated.
The sample document can be found here.
Thanks a lot!
Cheers,
Bharath
Code:
Sub CommandButton2_Click()
Dim x As Long
lastrow = Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
For x = 2 To lastrow
If Cells(x, 13).Value <> "TRUE" Then
'Cells(x, 11).Select
'Selection.Copy
'Cells(x, 6).Select
'Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Cells(x, 11).Select
'Cells(x, 13)= Application.Sum(Range(Cells(x, 6), Cells(x, 10))
ActiveCell.FormulaR1C1 = "=RC[-5]+RC[-1]"
Application.CutCopyMode = False
'ActiveCell.FormulaR1C1 = "FALSE"
'Cells(x, 13).Select
ElseIf Cells(x, 13).Value <> "FALSE" Then
Cells(x, 6).Select
Selection.Copy
Cells(x, 11).Select
Selection.Paste
End If
Next x
End Sub