Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Old April 24th 19, 09:26 AM
Junior Member
 
First recorded activity by ExcelBanter: Dec 2018
Posts: 4
Default VBA auto sort multicolumn table when data is changed/deleted in protected sheet mode

I use the code to automatically sort the table by attribute "Name" from column B.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error Resume Next
If Not Intersect(Target, Range("A:Z")) Is Nothing Then
Range("B5").Sort Key1:=Range("B6"), _
Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End If
End Sub

The first problem with this code is that when I delete a record after the first line remains an empty cell.
The second problem is how to make the code work while sheet is password-protected.
Protected password can be found in sheet PASS.

This is the WeTransfer link to an Excel file: https://we.tl/t-00zqVQgx82

Last edited by Roumen Roussev : April 26th 19 at 11:03 AM Reason: I'm sorry, but I realized the open post was not in the correct thread.

  #2   Report Post  
Old April 25th 19, 06:08 AM posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
First recorded activity by ExcelBanter: Apr 2015
Posts: 1,042
Default VBA auto sort multicolumn table when data is changed/deleted in protected sheet mode

Be careful that code line wrap doesn't occur after pasting. Split lines use...

" _"

...at the end. Otherwise all lines are single lines.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
  #3   Report Post  
Old April 26th 19, 11:06 AM
Junior Member
 
First recorded activity by ExcelBanter: Dec 2018
Posts: 4
Default Mistake

I'm sorry, but I realized that the opened post was not in the correct thread.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chartobjects protected but it can still be deleted, edited and movedby the user (yes, the sheet is protected) tskogstrom[_2_] Excel Programming 5 December 19th 14 11:56 AM
Auto filter sort ascending not working while sheet protected TommyB Excel Worksheet Functions 6 March 17th 10 02:51 PM
Unable to sort protected table OMER Excel Programming 9 September 20th 09 03:22 AM
Refresh Pivot table data in Protected sheet Sumanthkaka Excel Discussion (Misc queries) 3 July 16th 09 05:25 AM
Unable to open excel sheet in Protected mode from VB 6.0 ourspt Setting up and Configuration of Excel 0 January 26th 05 11:07 AM


All times are GMT +1. The time now is 11:45 PM.

Powered by vBulletin® Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright 2004-2019 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"

 

Copyright © 2017