logo elektroda
logo elektroda
X
logo elektroda

Creating a User Form in VBA for Adding and Deleting Database Entries in Excel

misiek294 7104 4
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 16415217
    misiek294
    Level 2  
    Hello, how to create a window using VBA in which I will add or delete data to an already created database?

    Additionally, you can expand it in the window and choose from existing ones. Enter the date and quantity.

    Best regards.
  • ADVERTISEMENT
  • Helpful post
    #2 16415330
    lanzul
    Level 30  
    misiek294 wrote:
    Hello, how to create a window using VBA in which I will add or delete data to an already created database?

    Additionally, you can expand it in the window and choose from existing ones. Enter the date and quantity.

    :D :D :D
    Complete beginnings, from the beginning, with the initial bud?
    Przykład ..na.zip Download (17.73 kB)
  • ADVERTISEMENT
  • #3 16415566
    misiek294
    Level 2  
    Thanks, that's what I meant :D
    I hope I can modify this window.

    
    Sub ini()
    Dim wartosc2 As Variant
    
    wartosc2 = Array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N") '14 wpisów
    
    

    Do you have to enter these values manually?
    I have them in the database of over 30 numbers and names.

    Added after 1 [hours]:

    So it's about such a base -
    After entering the data, the entire row should be added or deleted.
  • ADVERTISEMENT
  • #4 16416247
    lanzul
    Level 30  
    misiek294 wrote:
    ... value2 = Array ("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K" , "L", "M", "N") '14 entries

    Do you have to enter these values manually?
    I have them in the database of over 30 - numbers and names ...

    It was supposed to be just an example :D ... sure you don't need ... :D

    To review changes in " ini "," dopisz_do_bazy " and " usun_z_bazy "
    Przykład o...i_0001.zip Download (20.55 kB)
    :D

    For many lists to fill, you just need to 'multiply' variables such as' value2 '', give them proper names and instructions for counting the number of nonblank rows in a given column (less than 1 row per header), calculate the number of entries to insert into the given list and assign them to the property ' .Letter() "given list.

    Instructions for counting the number of non-empty cells have different forms depending on the preferences of those using them, for me it is, for example, the sheet function " COUNT () "or in Polish" COUNTA () " as:
    " w = Application.CountA (ThisWorkbook.Sheets (settings). Columns (1)) "
    in other words, non-empty rows calculated after the column "A" = Columns (1)

    Others prefer to use it for this' pure vba syntax ' as:
    w = ThisWorkbook.Sheets (settings). Cells (Rows.Count, 1). End (xlUp). Row
    or
    w = ThisWorkbook.Sheets (settings) .Range ("a1"). CurrentRegion.Rows.Count .
    where the column number in which non-empty cells are counted is one in "Cells (Rows.Count, 1 ) "and letter" and "in Address Range (" a1 ").
    In option with " CurrentRegion.Rows "you just have to be careful that the single-column spacing between data for lists is kept, otherwise the command 'will select the column with the most entries for counting'.
    And then it's just a loop ... :| ... :-) ...:
    Code: VBScript
    Log in, to see the code

    ... and assigning the variable to .List () of the given list.

    The output value of the completed list, but with an unselected entry on it is:
    UserForm1.ComboBox1 .ListIndex = -1
    Code: VBScript
    Log in, to see the code

    and the following:
    Code: VBScript
    Log in, to see the code

    is the setting for displaying two columns with data in the drop-down list " .ColumnCount = 2 ", indicating that the data from the first column are to be rewritten to the spreadsheet" .TextColumn = 1 "and a" .ColumnWidths = "100; 50 "is the corresponding width of the column data in the drop-down list.
    And here is a small complication - in the case of 'single-column' lists, rewriting data to the worksheet as in the example below:
    Code: VBScript
    Log in, to see the code

    , while in the case of 'suction' lists, data from multidimensional arrays must already refer to the given entries after indexes, i.e. if we have assigned two data to the variable, e.g. employee's name and his identifier, and this table looks like employee's data (index1, index2), where index1 are subsequent names, and index2 is identifiers and the variable 'increased' as below:
    Code: VBScript
    Log in, to see the code

    then rewriting to the worksheet looks like this:
    Code: VBScript
    Log in, to see the code

    If we set a different way of filling the board, then you have to rearrange this and that ...
    ... and if I twisted and twisted something here, then my colleagues from the forum will certainly improve ... so that they don't "put away from honor and faith" too much ... :D :?:
  • #5 16466408
    misiek294
    Level 2  
    Hey, I need to do an excel storage file.
    I made a pattern more or less what it looks like, but I can't insert button functions in vba code.
    Thank you in advance if someone wants to look at it and possibly give me some tips ;)
    Best regards !
ADVERTISEMENT