Delete range of rows

CampbellC

New Member
Joined
Dec 10, 2021
Messages
18
Office Version
  1. 365
Platform
  1. Windows
i would like to delete a range of cells instead of deleting entire row from list box
reason being i have other data in other rows that i don't wont to delete
range to delete A:N and keeping the data in O:R
eg row num 23 delete selected row up to Col N
and move the rows up 1
currently using this code to delete the entire row
hope this is understandable in what am trying to achieve
Screenshot 2021-12-19 195519.png

VBA Code:
Dim I As VbMsgBoxResult
Dim irow As Long


If Selected_list = 0 Then

MsgBox "No Record Selected", vbOKOnly + vbInformation, "Delete"

Exit Sub
End If


irow = Application.WorksheetFunction.Match(Me.lstdatabase.List(Me.lstdatabase.ListIndex, 0), _
ThisWorkbook.Sheets("products").Range("A:A"), 0)

I = MsgBox("Do you want to delete the selected record?", vbYesNo + vbQuestion, "confirmation")

If I = vbNo Then Exit Sub

ThisWorkbook.Sheets("products").Rows(irow).Delete

Call ProductsFrmStart

MsgBox "Selected record has been Deleted", vbOKOnly + vbInformation, "Delete"

End Sub
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Try replacing:

VBA Code:
ThisWorkbook.Sheets("products").Rows(irow).Delete

with:

VBA Code:
ThisWorkbook.Sheets("products").Range("A" & irow & ":N" & irow).Delete Shift:=xlUp
 
Upvote 0
Solution

Forum statistics

Threads
1,213,536
Messages
6,114,202
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top