Delete visible range without deleting entirerow

mumps

Well-known Member
Joined
Apr 11, 2012
Messages
12,151
Office Version
  1. 2013
  2. 2010
Platform
  1. Windows
I have the following code which filters column C and then I want to delete the visible range in columns A to E without deleting the entire row. Unfortunately, the code deletes the entire row which is problematic because i have data in columns to the right of column E which I want to keep. Any suggestions would be appreciated.
VBA Code:
Range("A3:F3").AutoFilter 3, "*Total*"
Range("A4" & ":E" & bottomC).SpecialCells(xlCellTypeVisible).Delete shift:=xlUp
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

EXCEL MAX

Well-known Member
Joined
Nov 11, 2020
Messages
672
Office Version
  1. 2016
Platform
  1. Windows
Hello Mumps,
I've got example and hopes that will be helpful.
VBA Code:
Sub DeleteShiftUp()
   
   Application.ScreenUpdating = False
   With ActiveSheet.Range("A1:F10")
      .AutoFilter 3, "*Total*"
      vA = ActiveSheet.Range("A2:F10").SpecialCells(xlVisible).Address
      .AutoFilter
      ActiveSheet.Range(vA).Delete Shift:=xlUp
   End With
   Application.ScreenUpdating = True
  
End Sub
 
Solution

mumps

Well-known Member
Joined
Apr 11, 2012
Messages
12,151
Office Version
  1. 2013
  2. 2010
Platform
  1. Windows
Thank you for your help. Much appreciated. :)
 

Forum statistics

Threads
1,176,096
Messages
5,901,375
Members
434,887
Latest member
zoath

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
Top