Consulting

Page 1 of 2 1 2 LastLast
Results 1 to 20 of 38

Thread: my excel vba stop running when i run the userform and not responding

  1. #1
    VBAX Regular
    Joined
    Jan 2018
    Posts
    40
    Location

    Exclamation my excel vba stop running when i run the userform and not responding

    hi

    Good Day!

    i dont know whats wrong with my excel codes.

    when i run will stop and excel not responding

  2. #2
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location
    Hi and welcome to the forum.

    As for an answer... Hmm.... I'm afraid we don't know either.

    Please provide more information and post the code that is failing (use the 'code tags' to wrap your code, the # button).

    Cheers

    Paul Ked
    Semper in excretia sumus; solum profundum variat.

  3. #3
    VBAX Regular
    Joined
    Jan 2018
    Posts
    40
    Location
    #Private Sub UserForm_Initialize()
    Dim i As Long, LastRow As Long, ws As Worksheet
    Set ws = Sheets("Sheet3")
    LastRow = ws.Range("B" & Rows.Count).End(xlUp).Row
    For i = 2 To LastRow 'if remove this FOR the userform show up'
        DoEvents
        Me.cmbiqama.AddItem ws.Cells(i, "B").Value
    Next i
    lblpayd.Caption = Format(Date, "Medium Date")
    ComboBox2.SetFocus
    textBASICSALARY.Value = 0
    textOVERTIME.Text = 0
    textFOOD.Text = 0
    textTRANS.Text = 0
    textOTHERS.Text = 0
    txtab.Text = 0
    txtlate.Text = 0
    txtloan.Text = 0
    txtpenalty.Text = 0
    opbcar = False
    opbwcn = False
    opboutcon = False
    With ComboBox1
        .AddItem "MALE"
        .AddItem "FEMALE"
    End With
    With ComboBox2
        .AddItem "6"
        .AddItem "8"
        .AddItem "9"
        .AddItem "10"
        .AddItem "12"
    End With
    With cmbxcountry
        .AddItem "BANGLADESH"
        .AddItem "EGYPTIAN"
        .AddItem "FILIPINO"
        .AddItem "INDIAN"
        .AddItem "NEPALI"
        .AddItem "MORROCO"
        .AddItem "SAUDI"
        .AddItem "SRI LANKA"
        .AddItem "SUDANESE"
        .AddItem "SYRIAN"
        .AddItem "PAKISTAN"
        .AddItem "TUNIZA"
         .AddItem "YEMENI"
    End With
    End Sub
    Last edited by Aussiebear; 04-15-2023 at 11:50 AM. Reason: Adjusted the code tags

  4. #4
    VBAX Regular
    Joined
    Jan 2018
    Posts
    40
    Location
    what's wrong with my FOR code?

  5. #5
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location
    Remove the DoEvents, that may be causing it to hang
    Semper in excretia sumus; solum profundum variat.

  6. #6
    VBAX Regular
    Joined
    Jan 2018
    Posts
    40
    Location
    what's wrong with my FOR code?

    i have removed the DoEvents still the userform1 still not showing

  7. #7
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location
    1. Did it stop the hanging?

    2. What are you using to call the UserForm Show?
    Semper in excretia sumus; solum profundum variat.

  8. #8
    VBAX Regular
    Joined
    Jan 2018
    Posts
    40
    Location
    1. it worsen excel now not responding

    2. when i press run or F5 excel not responding

  9. #9
    VBAX Regular
    Joined
    Jan 2018
    Posts
    40
    Location
    i cannot upload the file because it is larger than 1MB. 1.2MB to be exact.

  10. #10
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location
    Zip the file, then try
    Semper in excretia sumus; solum profundum variat.

  11. #11
    VBAX Regular
    Joined
    Jan 2018
    Posts
    40
    Location
    i zip the file still exceeds the limit

  12. #12
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location
    You could either:

    1. Take out any objects and stuff that is not required for the working (pictures etc) and save as a temporary file for upload,
    2. Save it to dropbox (or similar) and provide a link or
    3. Try save as an xlsb file, thay can be a bit smaller.
    Semper in excretia sumus; solum profundum variat.

  13. #13

  14. #14
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location
    My first question, probably of many, is WHY have you got 15,856 columns for employee data?

    My flabber has never been so ghasted!
    Semper in excretia sumus; solum profundum variat.

  15. #15
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location
    jouna payroll-Ked.xlsm

    1,048,559 rows for employees? That's quite a big company.

    I've shrunk your table to fit the data you have in it leaving a few columns for future.

    I've taken out the 2 Global Dim's that are causing confusion.

    I've removed the picture, pretty as it was, from sheet 4 to make the file size fit here. You can put that back in by all means.

    I've taken out the DoEvents which was superfluous.

    The form will open now, but i couldn't view all of it because of its size.
    Semper in excretia sumus; solum profundum variat.

  16. #16
    VBAX Regular
    Joined
    Jan 2018
    Posts
    40
    Location
    thats was my mistake hahaha. I have tried to change the stable colors and style. but it also changes the range automatically, i don't know why

    thank you very much for your help! very much appreciated!

    and my update button not working properly. i dont know whats wrong with my coding

  17. #17
    VBAX Regular
    Joined
    Jan 2018
    Posts
    40
    Location
    where is my mistake in the codings?
    thank you very much. you saved me .

  18. #18
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Run this code in a new workbook
    Public Sub ResetApplication()
    'Resets some application properties to default values
    
    With Application
    .EnableEvents = True
    .DisplayAlerts = True
    .ScreenUpdating = True
    .EnableCalculation = True
    .Calculation = xlCalculationAutomatic
    'And any other you might think of
    End With
    End sub
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  19. #19
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location
    Quote Originally Posted by Aihmar View Post
    where is my mistake in the codings?
    thank you very much. you saved me .
    I haven't the time to go through it, sorry, but if you step through each sub you'll find them, then post the errors here.
    Semper in excretia sumus; solum profundum variat.

  20. #20
    VBAX Regular
    Joined
    Jan 2018
    Posts
    40
    Location
    IQAMANo = Me.cmbiqama.Value
    Sheet3.Select
    Dim rowselect As Integer
    rowselect = Me.cmbiqama.Value
    rowselect = rowselect + 1
    Rows(rowselect).Select
    Cells(rowselect, 2) = Me.Textempnum.Value
    Cells(rowselect, 3) = Me.txtiqama.Value
    Cells(rowselect, 4) = Me.txtemployeename
    Cells(rowselect, 5) = Me.ComboBox1.Value
    Cells(rowselect, 6) = Me.cmbxcountry.Value
    Cells(rowselect, 7) = Me.ComboBox2.Value
    Cells(rowselect, 7) = Me.textBASICSALARY.Value
    Cells(rowselect, 9) = Me.textFOOD.Value
    Cells(rowselect, 10) = Me.textTRANS.Value
    Cells(rowselect, 11) = Me.textOTHERS.Value
    Cells(rowselect, 8) = Me.textOVERTIME.Value
    Cells(rowselect, 13) = Me.txtab.Value
    Cells(rowselect, 14) = Me.txtlate.Value
    Cells(rowselect, 15) = Me.txtloan.Value
    Cells(rowselect, 16) = Me.txtpenalty.Value
    Cells(rowselect, 17) = Me.lbldeduc.Caption
    Cells(rowselect, 19) = Me.lblGROSSPAY.Caption
    Cells(rowselect, 20) = Me.lblnetpay.Caption
    Cells(rowselect, 23) = Me.txtemployer.Value
    Cells(rowselect, 24) = Me.ComboBox2.Value
    my update button does not update insted creating new data in a new row .
    the date is in row 166 when update it goes to row 319

    please help im confused.



    thank you very much
    Last edited by Aussiebear; 04-15-2023 at 11:52 AM. Reason: Adjusted the code tags

Posting Permissions

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