+ Reply to Thread
Results 1 to 16 of 16

NEED HELP!! Looking to delete a Row Range instead of entire row!!PLEASE HELP!!

  1. #1
    Registered User
    Join Date
    05-05-2018
    Location
    south africa
    MS-Off Ver
    2016
    Posts
    12

    NEED HELP!! Looking to delete a Row Range instead of entire row!!PLEASE HELP!!

    Hi there,

    Question! I have used VBA Userform to create a delete entry button with data entry from Column (B:F). It is currently set to delete the entire row but i only want the Row from Range (columns B to F), that the active cell is in to be deleted.

    what is the code needed?

    i.e. instead of : ActiveCell.EntireRow.Delete" , what do i need to use if i want a row ranged from columns B to F deleted from the active cell being in anyone of the cells from B to F ?

    your response will be highly apprecaited

  2. #2
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: NEED HELP!! Looking to delete a Row Range instead of entire row!!PLEASE HELP!!

    You could use:
    Please Login or Register  to view this content.
    BSB

  3. #3
    Registered User
    Join Date
    05-05-2018
    Location
    south africa
    MS-Off Ver
    2016
    Posts
    12

    Re: NEED HELP!! Looking to delete a Row Range instead of entire row!!PLEASE HELP!!

    Thanks BSB.. but it doesnt seem to do anything. my current command button is coded as follows:

    Private Sub CommandButtonDelete_Click()

    Dim sh As Worksheet
    set sh = Msgbox (:do you want to delete this record?", vbquestion + vbYesNo)
    If pk = 7 then exit sub
    sh.Unprotect " 0000"

    Range("B" & ActiveCell.Row & ":F" & ActiveCell.Row).Delete Shift:=x1Up
    sh.protect"0000"

    End If
    End Sub

  4. #4
    Registered User
    Join Date
    05-05-2018
    Location
    south africa
    MS-Off Ver
    2016
    Posts
    12

    Re: NEED HELP!! Looking to delete a Row Range instead of entire row!!PLEASE HELP!!

    Thanks BSB.. but it doesnt seem to do anything. my current command button is coded as follows:

    Private Sub CommandButtonDelete_Click()

    Dim sh As Worksheet
    set sh = ThisWorkBook.sheets(:Data")
    dim pk as integer
    If ActiveCell.Row >2 then
    pk = Msgbox (:do you want to delete this record?", vbquestion + vbYesNo)
    If pk = 7 then exit sub
    sh.Unprotect " 0000"

    Range("B" & ActiveCell.Row & ":F" & ActiveCell.Row).Delete Shift:=x1Up
    sh.protect"0000"

    End If
    End Sub

  5. #5
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: NEED HELP!! Looking to delete a Row Range instead of entire row!!PLEASE HELP!!

    Could you attach a desensitized version of your workbook?

    BSB

  6. #6
    Registered User
    Join Date
    05-05-2018
    Location
    south africa
    MS-Off Ver
    2016
    Posts
    12

    Re: NEED HELP!! Looking to delete a Row Range instead of entire row!!PLEASE HELP!!

    to give you more details. I know my data will populate each row from B to F with Data of one entry. but i want the Row (ranged from B to F) that my activeCell is in to be deleted. i.e. if i want my row 18 to be delete, i should be able to select any column in row 18 Between B and F and it should delete the entire row.

  7. #7
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: NEED HELP!! Looking to delete a Row Range instead of entire row!!PLEASE HELP!!

    I understand that, and the line of code I provided will do exactly that.

    Without a sample workbook it difficult to diagnose why it's not working for you.

    One thing I do see from the code you posted is a typo. You have "x1Up" rather than "xlUp".
    Change that and try it. If that still doesn't work then post the sample workbook.

    BSB

  8. #8
    Registered User
    Join Date
    05-05-2018
    Location
    south africa
    MS-Off Ver
    2016
    Posts
    12

    Re: NEED HELP!! Looking to delete a Row Range instead of entire row!!PLEASE HELP!!

    Thank you!!! it worked! thanks so much

  9. #9
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: NEED HELP!! Looking to delete a Row Range instead of entire row!!PLEASE HELP!!

    Happy to help

    Don't forget to mark the thread as SOLVED if you're happy you have a working solution.

    BSB

  10. #10
    Registered User
    Join Date
    05-05-2018
    Location
    south africa
    MS-Off Ver
    2016
    Posts
    12

    Re: NEED HELP!! Looking to delete a Row Range instead of entire row!!PLEASE HELP!!

    so that worked, but now i want to be able to do the same but with columns G to L. I copy pasted the code, but if there are entries for "concrete" in col B to F, row 2 and entries for "steel", in col G to L, Row 2, and i just want to delete the entry foir steel in row 2 (col G to L), what would be the coding then?

  11. #11
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: NEED HELP!! Looking to delete a Row Range instead of entire row!!PLEASE HELP!!

    Do you mean using the same button?

    BSB

  12. #12
    Registered User
    Join Date
    05-05-2018
    Location
    south africa
    MS-Off Ver
    2016
    Posts
    12

    Re: NEED HELP!! Looking to delete a Row Range instead of entire row!!PLEASE HELP!!

    yes using the same button

  13. #13
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: NEED HELP!! Looking to delete a Row Range instead of entire row!!PLEASE HELP!!

    Replace that line of code with the below:
    Please Login or Register  to view this content.
    BSB

  14. #14
    Registered User
    Join Date
    05-05-2018
    Location
    south africa
    MS-Off Ver
    2016
    Posts
    12

    Re: NEED HELP!! Looking to delete a Row Range instead of entire row!!PLEASE HELP!!

    yes, and so if im in the range of b to f, it will delete only the row i.e. 18 (g to f), but if i then go to row 16, in between G and L, then it will only delete 16 (G to L)

  15. #15
    Registered User
    Join Date
    05-05-2018
    Location
    south africa
    MS-Off Ver
    2016
    Posts
    12

    [SOLVED] NEED HELP!! Looking to delete a Row Range instead of entire row!!PLEASE HELP!!

    Thank you!! this solved it! how do i mark as solved?

  16. #16
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: NEED HELP!! Looking to delete a Row Range instead of entire row!!PLEASE HELP!!

    Excellent news

    Go back to your first post in the thread and just above that it says "Thread Tools". Click on that and select SOLVED.

    Have a good one.

    BSB

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Delete Entire Row Using My Range
    By Sabrina68 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-20-2016, 09:21 AM
  2. [SOLVED] Delete Filtered range not the entire row
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-24-2015, 09:22 AM
  3. [SOLVED] Delete entire row within named range
    By crywolf in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-29-2015, 03:56 PM
  4. VBA code to delete the FILTERED range and moving the cell up (dont Delete entire row)
    By mchilapur in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-14-2015, 07:48 AM
  5. [SOLVED] Delete Entire Row Range
    By rr1050 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-25-2014, 03:55 AM
  6. Not Date Range, Delete Entire Row
    By ajocius in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-24-2010, 10:17 AM
  7. Looping down a Range to delete entire row
    By sportsguy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-01-2005, 11:50 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