Posts by norie

    Re: Loop through values in userform to store in array


    What do you want to know?


    By the way, are you going to be sticking with the multiple rows of controls or are you considering the suggestion I made about using a listbox?


    If it's the former it's not a problem really though the code required might be a bit more complicated.

    Re: Loop through values in userform to store in array


    How exactly is the data organised?


    Are you working with merged cells?


    By the way you can extract the individual columns from the array using Application.Index.


    For example this will put the values from column 2 in the listbox into column C on Sheet1 starting at row 2.

    Re: Loop through values in userform to store in array


    It depends where you want to put the data.


    If we extend the last code I posted this will put the contents of the listbox on Sheet1 starting at A1.

    Code
    Sheets("Sheet1").Range("A1").Resize(UBound(arrData, 1) + 1, UBound(arrData, 2) + 1).Value = arrData

    Re: Loop through values in userform to store in array


    Not sure about the nested loop thing, what would that be used for?


    If you were using a listbox you can put all the data in an array in one go like this.

    Code
    Dim arrData()
    
    
        arrData = ListBox1.List
        
        ReDim Preserve arrData(UBound(arrData), ListBox1.ColumnCount - 1) ' resize to remove Nulls

    Re: Combobox.Value in Range do else


    Perhaps.

    Re: Loop through values in userform to store in array


    The controls seem to be consistently named so you should be able to loop through them using their names.


    Actually, I'll take that back, some of the controls are named consistently, specifically the first 3 rows on the Materials tab.


    If all the controls were named consistently you could use something like this.


    By the way, have you considered using a multi-column listbox, one line of controls and a command button for materials?


    The user would select/enter data in the line of controls and then click the command button to add them to the listbox.


    You could also have buttons to edit/delete rows in the listbox.


    With that setup it would be easier to work with the data on the Materials tab.

    Re: Copying certain sheets into one worksheet


    Try this.

    Re: Object Variable or With Block Variable not set. Quite confused here.:(


    Not 100% sure what you are doing but if you want the code to run when a change is made in A2:A10 try this.

    Re: Comma Between the CheckBox Values into one cell


    In your Iif statements you have ws.Range("J", lngWriteRow) it should be ws.Range("J" & lngWriteRow).


    By the way, here's another way you could handle the checkboxes.