Page 2 of 2 FirstFirst 12
Results 11 to 20 of 20

Thread: Speed Up ListBox Getting Updated Filled Very Slow

  1. #11
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    What exactly is happening? I didn't have your file to test it. I'm sure you can figure out what's going wrong where, since it's pretty straight forward...
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  2. #12
    Junior Member
    Join Date
    Oct 2012
    Posts
    26
    Rep Power
    0
    It updates the the 6 cells in 1 column 6 rows instead of updating the 6 cells in 1 row and 6 columns. See Example.xlsm
    Last edited by Tony; 02-06-2013 at 11:27 PM.

  3. #13
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    Try this then

    Code:
    .Cells(Rx1, 3).Resize(,6).Value = var
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  4. #14
    Junior Member
    Join Date
    Oct 2012
    Posts
    26
    Rep Power
    0
    Great works FAST :D

    Last question... what do i need to change when working with multitabs and multiple listboxes. I tried to use the code below.

    Code:
    Private Sub CommandButton2_Click()
        Dim var(3 To 8) As String
        Dim j As Long
        Dim x As Long
    
        If Me.ListBox2.ListIndex = -1 Then
            MsgBox "No Data Selected"
            Exit Sub
        End If
    
        If Me.TextBox2.Value = "" Then Exit Sub
    
        Rx2 = Rx2 + Me.ListBox1.ListIndex    'row index
        With Sheets("INPUT BS LISTBOX")
            For j = 3 To 8
                 var(j) = Me.Controls("TextBox" & j + 8).Text 'Starts in Textbox 9
        Next j
                .Cells(Rx2, 3).Resize(, 6).Value = var
        End With
        Call UserForm_Initialize
    End Sub

  5. #15
    Junior Member
    Join Date
    Oct 2012
    Posts
    26
    Rep Power
    0
    Got a question about the code i used couple of days. When i typed for example 3 in my textbox and i pushed on update it showed automatically 3% but with the new code it does not take over the cell property's how can.

    OLD CODE (fills cell format e.g. 3 will be automatically 3%)
    Code:
    Private Sub CommandButton2_Click()
        Dim j As Long
        Dim x As Long
    
        If Me.ListBox1.ListIndex = -1 Then
            MsgBox "No Data Selected"
            Exit Sub
        End If
        If Me.TextBox1.Value = "" Then Exit Sub
        Rx1 = Rx1 + Me.ListBox1.ListIndex   
        With Sheets("INPUT WV LISTBOX")
            For j = 8 To 10 
                .Cells(Rx1, j).Value = Me.Controls("TextBox" & j - 3).Text
            Next j
        End With
        Call UserForm_Initialize
    End Sub
    NEW CODE FAST (but puts only the value in the box e.g. 3 stays 3.)
    Code:
    rivate Sub CommandButton2_Click()
        Dim var(3 To 8) As String
        Dim j As Long
        Dim x As Long
    
        If Me.ListBox1.ListIndex = -1 Then
            MsgBox "No Data Selected"
            Exit Sub
        End If
        If Me.TextBox1.Value = "" Then Exit Sub
        Rx1 = Rx1 + Me.ListBox1.ListIndex
        With Sheets("INPUT WV LISTBOX")
            For j = 3 To 8
            var(j) = Me.Controls("TextBox" & j).Text
            Next j
            .Cells(Rx1, 3).Resize(, 6).Value = var
        End With
        Call UserForm_Initialize
    End Sub
    Last edited by Tony; 02-09-2013 at 01:04 AM.

  6. #16
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    try
    Code:
    .Cells(Rx1, 3).Resize(, 6).Formula = var
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  7. #17
    Junior Member
    Join Date
    Oct 2012
    Posts
    26
    Rep Power
    0
    Just tested but not working

  8. #18
    Senior Member
    Join Date
    Jun 2012
    Posts
    337
    Rep Power
    13
    Why don't you post a sample workbook ???

  9. #19
    Junior Member
    Join Date
    Oct 2012
    Posts
    26
    Rep Power
    0
    Quote Originally Posted by snb View Post
    Why don't you post a sample workbook ???
    See Example.xlsm

    When i use
    Code:
    .Cells(Rx1, 3).Resize(6).Value = Application.Transpose(var)
    it works but then the data wil be placed in 1 column

    When i use
    Code:
    .Cells(Rx1, 3).Resize(, 6).Value = var
    it places the content in 6 column on 1 row what i need but then the cell propertys will not be used

  10. #20
    Junior Member
    Join Date
    Oct 2012
    Posts
    26
    Rep Power
    0

    Solved

    Solved the problem using
    Code:
    .Cells(Rx1, 3).Resize(, 6).Value = Application.Transpose(var)
    one small change...but don't know why that function application.transpose does the trick.

Similar Threads

  1. Speed up excel to word VBA
    By bcostin in forum Excel Help
    Replies: 3
    Last Post: 05-22-2012, 10:49 AM
  2. Get the last updated file name.
    By princ_wns in forum Excel Help
    Replies: 3
    Last Post: 04-12-2012, 07:59 AM
  3. Speed up Loop VBA
    By PcMax in forum Excel Help
    Replies: 15
    Last Post: 04-09-2012, 04:20 PM
  4. Get last Filled Cell address in a Range.
    By Rajan_Verma in forum Rajan Verma's Corner
    Replies: 3
    Last Post: 03-24-2012, 01:08 AM
  5. Last Filled Cell Having Text
    By Excel Fox in forum Excel and VBA Tips and Tricks
    Replies: 5
    Last Post: 07-18-2011, 02:33 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
  •