Hi Alan,
I will try to explain exactly what should happen with my file:
1. when I click on "Form" button located in sheet1 a user form open and I enter all the data in this form (file attached in .jpg for you to see)
2. I fill all the data in this form (there are some dropdown lists-except the Amount) for each field. The fields from user form are exactly the headers from column B to G located in Database sheet (Year, Month, Name, Project, Task, Amount)-see File1.jpg attached.
3. When I click "SAVE" all the data are automatically added in Database sheet as a new line (less columns A and H that are auto filled) - please see File2.jpg attached.
This is done by the following code and it is working just fine
4. Now comes the part where I need help. I would like that when I click the "SAVE" button in my user form to add a new line in Database sheet as pct. 3 above (this is already working as described before) AND to add only the amount of 1000 to cell G20 from Database1 sheet (please see File3.jpg attached). That cell is the correspondent cell for the data that I filled in user form - Year 2022, Month April, Name bbb, Project Project5, Task Task2 as File1.jpg.Code:Sub Submit_Data() Dim sh As Worksheet Dim sh1 As Worksheet Dim iRow As Long, colno As Integer, iCol As Long, rowno As Integer Dim iRow1 As Long, colno1 As Integer, iCol1 As Integer, reqdRow As Integer Set sh = ThisWorkbook.Sheets("Database") Set sh1 = ThisWorkbook.Sheets("Database1") iRow = [Counta(Database!A:A)] + 1 iCol = Sheets("Database").Cells(1, Columns.Count).End(xlToLeft).Column - 1 iRow1 = [Counta(Database1!A:A)] + 1 iCol1 = Sheets("Database1").Cells(1, Columns.Count).End(xlToLeft).Column - 1 Application.ScreenUpdating = False With sh .Cells(iRow, 1) = iRow - 1 .Cells(iRow, 2) = UserFormTest.CmbYear.Value .Cells(iRow, 3) = UserFormTest.CmbMonth.Value .Cells(iRow, 4) = UserFormTest.CmbName.Value .Cells(iRow, 5) = UserFormTest.CmbProject.Value .Cells(iRow, 6) = UserFormTest.CmbTask.Value .Cells(iRow, 7) = UserFormTest.TxtAmount.Value .Cells(iRow, 8) = Application.UserName End With Call Reset Application.ScreenUpdating = True MsgBox "Date incarcate cu succes!" End Sub
Hope it make sense now.
Thanks again!
P.S. The link sent before for downloading the file was great but the issue with the amount from Database1 sheet didn't worked




Reply With Quote
Bookmarks