# Md. Abdul Kader

Hi! I am Abdul Kader and presently working as â€˜Excel & VBA Content Developerâ€™ at Exceldemy. I publish my articles related to Microsoft Excel here. In 2019, I completed my graduation in Urban and Regional Planning from Chittagong University of Engineering and Technology. Having extreme eagerness to learn, I want to develop my skills and capabilities higher.

## How to Make Subtotal and Grand Total in Excel (4 Methods)

Whenever you have a larger dataset and you want to compute subtotal for a specific field or some specific group and grand total covering the entire dataset. In ...

## How to Extract Multiple Numbers from String in Excel (6 Methods)

Most likely, you have heard about extracting only numbers. But you might need to extract multiple numbers. That means you may have numeric values before a ...

## How to Create Rows within a Cell in Excel (3 Methods)

In this instructive session, Iâ€™ll show you 3 handy methods on how to create rows within a cell in Excel. Watch Video â€“ Create Rows within a Cell in ...

## Ranking Based on Multiple Criteria in Excel (4 Cases)

Often you may need to rank items from a dataset based on multiple criteria. More specifically, you have to accomplish this task when there are ties in one ...

## How to Freeze Random Selection in Excel

Often you need to generate random numbers or strings for specific purposes, especially in the case of statistical sampling. However, you have to freeze the ...

## How to Use Formula for Partial Number Match in Excel (5 Examples)

Frequently, you might need to deal with a larger dataset in Excel. What if you want to find the output from the entire dataset that matches your defined ...

## How to Merge Excel File into Word Document (2 Cases)

While working in Excel, you might need to merge the file to Word for preparing a report or something else. As these applications are part of Office, owned by ...

## How to Insert a Column to the Left in Excel (6 Methods)Â

While working in Excel, you might need to insert a new column if you missed it earlier. Certainly, you can accomplish the simple but necessary task within ...

## [Fixed!] Sort and Filter Not Working in Excel

Sort is such a powerful tool that can organize text, numbers, and dates. Besides, you can easily retrieve your data based on your requirements using the Filter ...

## How to Print Excel Sheet with Table (4 Methods + Tricks)

Most likely you know about the process of printing an Excel sheet. What if you want to print the sheet with a table? In this article, Iâ€™ll show 4 methods as ...

## How to Filter Based on Cell Value Using Excel VBA (4 Methods)

When you have a larger dataset and you want to apply the filters based on a certain value, using the VBA code might be the best option. In this article, Iâ€™ll ...

## [Fix]: Excel Wrap Text Cutting off Words

Frequently, you may need to wrap the text for some specific reasons especially to avoid overflowing the text. Unfortunately, you might have faced the issue of ...

## How to Find Duplicates in Two Different Excel Workbooks (5 Methods)

While working in Excel, you might need to find duplicates in two different workbooks for identifying, modifying, or even removing those duplicates. In this ...

## [Solution:] Excel Wrap Text Not Working for Merged Cell

Often you might need to wrap text over merged cells while working in Excel. Especially, if the string inside the cells is quite large. Unfortunately, you may ...

## How to Do Linear Interpolation in Excel (7 Handy Methods)

Sometimes you may need to create a new data point from the given range of known data points. In such a situation, you might accomplish linear interpolation in ...

Browsing All Comments By: Md. Abdul Kader
1. Hello EAC,
Thanks for your question. Most likely, you need to put a not equal sign (<>) inside the Ifâ€¦Then statement of your second code. So, the corrected second code will be as follows-

``````Sub block()
Dim hz As String
Dim hz1 As String

hz1 = InputBox("repeat password")

If hz <> hz1 Then
MsgBox "The repeated password is not identical!", vbExclamation
hz = ""
hz1 = ""
Else
Columns("D:F").Select
Selection.Locked = False
Range("D8:F12").Select
Selection.Locked = True
Range("a1").Select
ActiveSheet.Protect hz
End If
End Sub``````

However, your used three codes are quite messy. I would like to suggest that you can use the following code to lock a specific cell range in all worksheets of your Excel file.

``````Sub Lock_CellRange_AllSheets()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Unprotect Password:="1234" 'Replace the password if you want
ws.Range("D8:F12").Locked = True 'Replace the cell range
ws.Protect Password:="1234", UserInterfaceOnly:=True 'Replace the password with the actual password for the workbook if it is protected
Next ws
End Sub``````

Again, try this code to unlock the specific cell range in all worksheets.

``````Sub Unlock_CellRange_AllSheets()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Unprotect Password:="1234" 'Replace the password if you want
ws.Range("D8:F12").Locked = False 'Replace the cell range
ws.Protect Password:="1234", UserInterfaceOnly:=True 'Replace the password with the actual password for the workbook if it is protected
Next ws
End Sub``````

I hope these will work! Moreover, you can follow lock and unlock cells using VBA to explore more efficient methods.

2. Hello Michael,
Please specify your problem in detail or send the excel file via [email protected] email address.

3. Dear Deka,
It’s nice to hear from you with such wonderful appreciation. I myself always try to represent Excel applications in a more user-friendly way. And we, the ExcelDemy team, are working as a one-stop Excel solution provider.
Thanks, and take care of yourself. Goodbye!