VBA to Remove Blank Range/cell (select columns) & Move Next Row Up

WildBurrow

New Member
Joined
Apr 5, 2021
Messages
41
Office Version
  1. 365
Platform
  1. Windows
I have a sheet with three groupings of data; REMOVED, RETURNED, & SUSPENDED. I'd like the User to be able to remove data from the 'RETURNED' group. If they do, columns F:H would become empty/blank.

I'd need to figure out how to find this blank section and move the next row of data up - without impacting the adjacent columns AND without bringing up the last visible row (27) which is a colored-filled border for the sheet.

I've tried several iterations of the following, such as:
VBA Code:
 Range("F:F").SpecialCells(xlBlanks).Delete xlUp
or
VBA Code:
 Range("F4:F26").SpecialCells(xlBlanks).Delete xlUp
but doing so pulled row 27 upward (which are color-filled cells which function as a border to the sheet) and removed the cell borders.

Falling short of using an iteration of the above then replacing cell borders and refilling color to row 27, is there a more concise method to use?

Finally, my apologies for attaching an image. I work for an organization that will not allow me to download XL2BB nor allow me access to Box.com or DropBox.com :rolleyes:.

Thanks

1678808267611.png
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Try:
VBA Code:
Sub deleteBlankRange()
    Application.ScreenUpdating = False
    With Range("F27:H27")
        .Interior.ColorIndex = xlNone
        .Borders.LineStyle = xlNone
    End With
    Range("F4:H26").SpecialCells(xlCellTypeBlanks).Delete shift:=xlUp
    With Range("F27:H27")
        .Interior.ColorIndex = 3
        .Borders.LineStyle = xlContinuous
    End With
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Solution
Try:
VBA Code:
Sub deleteBlankRange()
    Application.ScreenUpdating = False
    With Range("F27:H27")
        .Interior.ColorIndex = xlNone
        .Borders.LineStyle = xlNone
    End With
    Range("F4:H26").SpecialCells(xlCellTypeBlanks).Delete shift:=xlUp
    With Range("F27:H27")
        .Interior.ColorIndex = 3
        .Borders.LineStyle = xlContinuous
    End With
    Application.ScreenUpdating = True
End Sub
Mumps

Well, that is a lovely, concise piece of code. Remove the color, delete the blanks, replace the color and border. Thank you for providing a lesson on how to not 'over-think' the issue and for providing your time to reply to my question. Very much appreciated.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,246
Members
452,623
Latest member
cliftonhandyman

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