Unlock entire row - condition

singh.jms

New Member
Joined
Apr 26, 2010
Messages
9
Hi...want to know.. If any cell in Column "A" has any text, then unlock that entire row for editing. For example, if cell "A3" has text, so All I want that the entire row 3 to be unlocked for editing.
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Hi and welcome to the board.

Try;
Code:
[COLOR="Blue"]Public[/COLOR] [COLOR="Blue"]Sub[/COLOR] UnlockRange()
    [COLOR="Blue"]Dim[/COLOR] rngFilter [COLOR="Blue"]As[/COLOR] Range
    [COLOR="Blue"]Set[/COLOR] rngFilter = Range(Cells(1, 1), Cells(Rows.Count, 1).End(xlUp))
    
    [COLOR="Blue"]With[/COLOR] rngFilter
        .Parent.Unprotect Password:="password"
        .Parent.AutoFilterMode = [COLOR="Blue"]False[/COLOR]
        .AutoFilter field:=1, Criteria1:="<>"
        .Offset(1).SpecialCells(xlCellTypeVisible).EntireRow.Locked = [COLOR="Blue"]False[/COLOR]
        .End(xlDown).Offset(1).EntireRow.Delete
        .AutoFilter
        .Parent.Protect Password:="password"
    [COLOR="Blue"]End[/COLOR] [COLOR="Blue"]With[/COLOR]
    
[COLOR="Blue"]End[/COLOR] [COLOR="Blue"]Sub[/COLOR]
 
Upvote 0
Hey Thanks for the quick reply..

That doesn't seems to be working... I am new to writing VBA codes. I just copy pasted your suggested codes. I don't know why? If you could help more on that.
 
Upvote 0
You need to paste it into a standard module:

Open the VBE (ALT + F11)
Insert a new module (on the menu bar Insert > Module)
Paste the code in the new module and close the VBE.
To run hit ALT+F8 > UnlockRange > Run

Do you encounter any specific error? And if so can you tell me what line it breaks on?
 
Upvote 0
Look in my signature to download an addin that allows you to display your sheet on the board using HTML.
 
Upvote 0
Dear Von, Let me ask in different way..
If I add any text in a cell in Column "A" , then unlock that entire row for editing. For example, if I add any text in cell "A13", then the entire row 13 will get unlocked for editing.
 
Upvote 0
Ok, so I now assume that you want to unlock the row automatically as you input data in column A, right?

Right-click the sheet tab > view code > paste this code into the code pane that opens. Close the VBE again:

Code:
[COLOR="Blue"]Private[/COLOR] [COLOR="Blue"]Sub[/COLOR] Worksheet_Change([COLOR="Blue"]ByVal[/COLOR] Target [COLOR="Blue"]As[/COLOR] Range)
    [COLOR="Blue"]If[/COLOR] Application.Intersect(Target, Columns(1)) [COLOR="Blue"]Is[/COLOR] [COLOR="Blue"]Nothing[/COLOR] [COLOR="Blue"]Then[/COLOR] [COLOR="Blue"]Exit[/COLOR] [COLOR="Blue"]Sub[/COLOR]
    Me.Unprotect Password:="password"
    Target.EntireRow.Locked = [COLOR="Blue"]False[/COLOR]
    Me.Protect Password:="password"
[COLOR="Blue"]End[/COLOR] [COLOR="Blue"]Sub[/COLOR]

Assumes that column A is set to unlocked, and that all other remaining columns are locked.
 
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

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