Hi,
I have code to copy data from userform to SS sheet, but what I want show message box if I have missed month are not copied in FORM sheet and don't copy from form to SS sheet .
so on userform I suppose the current month is MAR as filled on form showing picture . and there are missed months in FORM sheet in this case I would match dates in textbox1,textbox2 with column A in FORM sheet so will be FEB is missed then should show message inform me how many missed months and their names " you have one missed month is FEB, so you should adjustment this problem" after message is gone then should not copy data from userform to SS sheet.
the code copy like this
here is code
and I want preventing to copy from form to SS sheet after show message.
and this sheet to match textbox1,textbox2 with column A
if there is no missed months then should copy from form to SS sheet.
last thing if I try date in TB1,TB2 and month is existed in FORM sheet then show message " this month is already existed and clear TB1,TB2 after message is gone .
thanks.
I have code to copy data from userform to SS sheet, but what I want show message box if I have missed month are not copied in FORM sheet and don't copy from form to SS sheet .
so on userform I suppose the current month is MAR as filled on form showing picture . and there are missed months in FORM sheet in this case I would match dates in textbox1,textbox2 with column A in FORM sheet so will be FEB is missed then should show message inform me how many missed months and their names " you have one missed month is FEB, so you should adjustment this problem" after message is gone then should not copy data from userform to SS sheet.
the code copy like this
al.xlsm | ||||||
---|---|---|---|---|---|---|
A | B | C | D | |||
1 | FROM DATE | TO DATE | NAME | FIRST BALANCE | ||
2 | 01/01/2025 | 31/01/2025 | ALI | -3,000.00 | ||
3 | SALARY | 2,000.00 | ||||
4 | AMOUNT | -1,000.00 | ||||
5 | ||||||
6 | ||||||
7 | FROM DATE | TO DATE | NAME | FIRST BALANCE | ||
8 | 01/01/2025 | 31/01/2025 | ALILA | 2,000.00 | ||
9 | SALARY | 1,000.00 | ||||
10 | AMOUNT | 3,000.00 | ||||
SS |
here is code
VBA Code:
Private Sub CommandButton1_Click()
Dim Fnd As Range, Nxt As Long
With Sheets("SS")
Nxt = .Cells(.Rows.Count, 3).End(xlUp).Row + 2
If Nxt = 2 Then Nxt = 1
Set Fnd = .Range("C:C").Find(TextBox3, , xlValues, xlWhole)
If Not Fnd Is Nothing Then Nxt = Fnd.Row - 1
With .Cells(Nxt, 1).Resize(, 4)
.Value = Array(Label1, Label2, Label3, Label4)
.Interior.Color = RGB(255, 102, 0)
End With
.Cells(Nxt + 1, 1).Resize(, 4) = Array(TextBox1, TextBox2, TextBox3, TextBox4.Value)
.Cells(Nxt + 2, 3).Resize(, 2) = Array(Label6, TextBox5.Value)
.Cells(Nxt + 3, 3).Resize(, 2) = Array(Label5, TextBox6.Value)
.Cells(Nxt + 2, 3).Resize(2).Interior.Color = RGB(255, 102, 0)
.Cells(Nxt, 1).Resize(2, 4).Borders.Weight = 2
.Cells(Nxt + 2, 3).Resize(2, 2).Borders.Weight = 2
End With
End Sub
and this sheet to match textbox1,textbox2 with column A
al.xlsm | ||||||
---|---|---|---|---|---|---|
A | B | C | D | |||
1 | MONTH | ITEM | NAME | BALANCE | ||
2 | Jan-25 | 1 | ALI | 2,000.00 | ||
3 | 2 | ALILA | 1,000.00 | |||
4 | TOTAL | -9,000.00 | ||||
FORM |
if there is no missed months then should copy from form to SS sheet.
last thing if I try date in TB1,TB2 and month is existed in FORM sheet then show message " this month is already existed and clear TB1,TB2 after message is gone .
thanks.