Results 1 to 10 of 12

Thread: User Form entry in a second sheet - need help with VBA code

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    10,457
    Rep Power
    10
    Hi
    I am not sure what hte problem is with the download for you. Once in a while something wont download on a particular operating system or Browser. We never figured out why yet.
    I just put it in a share place for you, perhaps that will work for you
    Share ‘Work_file.xlsm’ https://app.box.com/s/v9ifgeicp6nzha0axcha3qcprzgprgob

    It's difficult for me to help further beacuse
    _1 I can't see anything on the userform - as i showed in the screen shot the text and numbers are too small to see,
    _ 2 I still really don't know what should happen.I don't understand what you want, where data comes from etc. etc... - You have given a pefectly good explanation for yourself or anyone else maybe who knows already the sort of thing that you are doing.
    But you are talking to a complee stranger that knows VBA quite well but has no idea of your work. (and hasn't done much with userforms either - I do understand the very basics of them). I expect it would take me 10 seconds to sort your problem out , but a day first before I figured out what it is that should happen.
    You will always improve your chances of an answer here, or elsewhere, if you give a very detailed walkthrough of what should happen , giving sample data and saying exactly what steps you do, where the data is coming from etc. etc
    I feel your pain. You have an annoying problem and want the answer quick. Sometimes you strike lucky, and find someone that has done almost excactly what you are doing and sees at a glance what the problem is.
    I hav'nt, so I can't

    Alan
    Last edited by DocAElstein; 02-18-2022 at 02:27 PM.
    ….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
    If you are my enemy, we will try to kick the fucking shit out of you…..
    Winston Churchill, 1939
    Save your Forum..._
    KILL A MODERATOR!!

  2. #2
    Junior Member
    Join Date
    Feb 2022
    Posts
    11
    Rep Power
    0
    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
    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
    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.

    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
    Attached Images Attached Images

Similar Threads

  1. Inserting Image In VBA User Form Caption
    By littleiitin in forum Download Center
    Replies: 3
    Last Post: 02-22-2021, 03:07 PM
  2. create invoice with user form
    By anil21 in forum Excel Help
    Replies: 7
    Last Post: 02-07-2018, 04:57 PM
  3. VBA Code for User Form
    By dkesar in forum Excel Help
    Replies: 1
    Last Post: 01-02-2015, 03:19 PM
  4. Replies: 5
    Last Post: 06-13-2014, 08:37 PM
  5. Replies: 7
    Last Post: 03-11-2014, 05:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •