While it does the work, when cells are merged you will not be able to sort the data.
In case you are working with a worksheet with merged cells, use the code below to unmerge all the merged cells at one go.
While writing an Excel VBA macro code may take some time initially, once it's done, you can keep it available as a reference and use it whenever you need it next.
In this massive article, I am going to list some useful Excel macro examples that I need often and keep stashed away in my private vault.
Name If you have a lot of worksheets in a workbook and you want to protect all the sheets, you can use this macro code.
In case the example says that you need to paste the code in the worksheet code window, double click on the worksheet object and copy paste the code in the code window. Once you have copied the code in the VB Editor, here are the steps to run the macro: In case the code is pasted in the worksheet code window, you don't need to worry about running the code.
Once you have inserted the code in a workbook, you need to save it with a . It will automatically run when the specified action occurs.
Protect password:=password Next ws End Sub'This code will protect all the sheets at one go Sub Protect All Sheets()Dim ws As Worksheet Dim password As Stringpassword = "Test123" 'replace Test123 with the password you want For Each ws In Worksheetsws.
Unprotect password:=password Next ws End Sub It's a common practice to merge cells to make it one.