Results 1 to 5 of 5

prevention to delete selected item for the first & lastrow from listbox on userform

Threaded View

Maklil prevention to delete ... 01-11-2023, 05:17 AM
Artik Re: prevention to delete ... 01-11-2023, 01:11 PM
Maklil Re: prevention to delete ... 01-11-2023, 01:33 PM
Artik Re: prevention to delete ... 01-11-2023, 02:05 PM
Maklil Re: prevention to delete ... 01-11-2023, 02:20 PM
  1. #1
    Forum Contributor
    Join Date
    09-21-2022
    Location
    africa
    MS-Off Ver
    2019
    Posts
    182

    prevention to delete selected item for the first & lastrow from listbox on userform

    Hi
    I want when try delete selected item for the first or last row into listbox on userform should pops message "you have not permission to do that" ,otherwise I can delete the others selected items when select the items from combobox1:3 .
    here is the code
    Private Sub ButtonDeleteRow_Click()
      Dim i As Integer
      Application.ScreenUpdating = False
      
      If MsgBox("Are you sure you want to delete this data row?", vbYesNo + vbQuestion, "Delete Row?") = vbYes Then
        Worksheets("DETAILS").Select
        For i = Range("A" & Rows.Count).End(xlUp).Row To 1 Step -1
          If Cells(i, 1) = ListBox1.List(ListBox1.ListIndex) Then
            Rows(i).Delete
          End If
        Next i
      End If
      Application.ScreenUpdating = True
    End Sub
    thanks
    Attached Files Attached Files
    Last edited by Maklil; 01-11-2023 at 09:06 AM. Reason: adjusting title of thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Adding delete code on userform to delete a row on sheet by selecting item on a listbox
    By darbar76528 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 11-07-2020, 12:50 PM
  2. Delete selected item from ListBox with KeyDown event
    By esbencito in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-08-2020, 03:57 AM
  3. [SOLVED] how to get the next item value based on the selected item in userform listbox ?
    By karmapala in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-27-2019, 05:49 AM
  4. [SOLVED] Userform Listbox - Display selected item in cell
    By Neuk in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-22-2018, 03:39 PM
  5. Userform listbox - Getting Sheet row of selected item
    By johnny_p in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-14-2015, 05:00 AM
  6. [SOLVED] listindex=0 when first item selected in a multiselect listbox on a userform?
    By mcdermott2 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 04-17-2013, 12:38 PM
  7. Keep selected ListBox item highlighted when reopening userform
    By berlini in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-22-2011, 08:38 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1