Can someone please shorten this VBA code for me? For a userform

  • Hi There,


    I've never studied VBA, as a result I tend to do things the long way. Because there are so many combo boxes, this seems to be running slowly.


    Could someone let me know if there is a way to speed up this code? It's for a userform that's taking too long to initialise



    Thanks Heaps!

  • Re: Can someone please shorten this VBA code for me? For a userform


    Please read the Forum Rules before postingg again and use Code Tags when posting code


  • Re: Can someone please shorten this VBA code for me? For a userform


    Thankyou! Unfortunately, I'm getting an object required error.


    Any idea?

  • Re: Can someone please shorten this VBA code for me? For a userform


    All good found it!


    Code
    Each c In .Range("G:G", .Range("G" & Rows.Count).End(xlUp)) 
                If c.Value <> "" Then Me.ComboBox7.AddItem f.Value


    Type. Should be c instead of f. obviously missed the keyboard by a fraction!


    Thanks


    [COLOR="#FF0000"]Moderation Edit : please remember to add code tags to your VBA code[/COLOR]

  • Re: Can someone please shorten this VBA code for me? For a userform


    Just a thought...


    Maybe also the part where you populate the sheet could be shortened, code wise..(but not necessarily sped up)....


    Something like : (pseudo code)...

    Code
    For I = 1 To 21
             Cells(emptyRow, I).Value =  Choose(I, DTPicker1.Value, TextBox1.Value, etc etc)
    Next i
  • Re: Can someone please shorten this VBA code for me? For a userform


    You can use an array to write to the sheet


Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!