Delete rows even if they are header rows?

td_excelforum

New Member
Joined
Dec 3, 2021
Messages
6
Office Version
  1. 365
Platform
  1. Windows
I'm trying to delete some row before the occurence of a word ('datum'). In some sheets there are headers in the first row (classic Column1 etc) that I want to delete if they do not contain this word ('datum').

I'm failing in these sheets as headers are not deletable. Any ideas?

VBA Code:
  Set fRg = Cells.Find(What:="datum", LookAt:=xlWhole)
     
        If Not fRg Is Nothing Then
            If fRg.Row <> 1 Then
                    Range("A1", fRg.Offset(-1)).EntireRow.Delete
            Else
            End If
        Else
        End If
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
The header rows you are talking about must be the header of a Table. The header row of a table cannot be deleted. Why would you want to delete that? The only way to delete a table header row is to convert the table back to a range, delete the row, then convert back to a table. That is a little tricky if you have a cell address, but don't already know what table it is. But that could cause all kinds of other problems depending on how you use those tables.
 
Upvote 0

Forum statistics

Threads
1,214,952
Messages
6,122,457
Members
449,083
Latest member
Ava19

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