macro to delete table row/entry

rjmdc

Active Member
Joined
Apr 29, 2020
Messages
261
Office Version
365
Platform
Windows
Word of warning, with this at the top of the code
VBA Code:
Call WSUnProtect(Worksheets("Check Queue"))
If the first message box comes up, or they select No on the 2nd one, your sheet will be unprotected.
 

Some videos you may like

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

rjmdc

Active Member
Joined
Apr 29, 2020
Messages
261
Office Version
365
Platform
Windows
hi fluff
i am a bit confused
i tried your code
if the unprotect isnt on the top then user cannot choose a cell as the entire sheet is protected
however it isnt easy to choose a cell in column a when executing your code, it first asks to delete wherever the cursor happens to be
 

rjmdc

Active Member
Joined
Apr 29, 2020
Messages
261
Office Version
365
Platform
Windows
anyway whats the 8 all about?
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
42,669
Office Version
365
Platform
Windows
If the entire sheet is locked down, then you cannot use exit sub in the code.
Try selecting No on the message box & see what happens. ;)
 

rjmdc

Active Member
Joined
Apr 29, 2020
Messages
261
Office Version
365
Platform
Windows
hi
your macro allows a choice outside of column A
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
42,669
Office Version
365
Platform
Windows
Does that matter as long as the the selection is inside the table?
 

rjmdc

Active Member
Joined
Apr 29, 2020
Messages
261
Office Version
365
Platform
Windows
for sure as it is allowing deletion of the column titles
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
42,669
Office Version
365
Platform
Windows
It will not allow you delete the header row.
 

rjmdc

Active Member
Joined
Apr 29, 2020
Messages
261
Office Version
365
Platform
Windows
it did
what did i do wrong
i copied your code exactly
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
42,669
Office Version
365
Platform
Windows
It cannot delete the header row, because it's not part of the Data body range.
With this data
PostcodeIn Use?LatitudeLongitudeEastingNorthingGridRef
S36 1GJYes53.472455-1.601497426549397376SK265973
OL4 4BAYes53.546558-2.059182396176405548SD961055
DE4 2BUYes53.145179-1.664349422548360945SK225609
BD6 3FHYes53.767997-1.803484413051430201SE130302
BD20 6QXYesAED-1.952001403253442777SE032427
HD3 3UHYes53.659087-1.853093409806418076SE098180
HD7 3EBNoAED-1.826124411609409593SE116095
DH8 5EJYes54.853973-1.839415410408551031NZ104510
DL8 5JZYesAED-1.850724409807492011SE098920
S10 3PHYesAED-1.539468430738386290SK307862
DL8 3SHYesAED-2.200844387027489389SD870893
HD3 3GSYes53.659793-1.842574410501418156SE105181


If I selected any cell in A1:G1, this message box would be displayed
VBA Code:
MsgBox "You need to select a cell within the table"
 

Watch MrExcel Video

Forum statistics

Threads
1,102,351
Messages
5,486,357
Members
407,541
Latest member
Emilybuhman

This Week's Hot Topics

Top