Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Please Help!!!! If statement, lock and unlock cells

Hi,

The spreadsheet has 2000 records and 30 columns. There are many blanks so I
just want to lock all the data that fill in cells and unlock for blank cells
for me to input the data. Is there a way to make the cell turn to bold
where I update the blank cell only.

Please help!!! Your help would be much apprecated.

Thanks.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Please Help!!!! If statement, lock and unlock cells

Hi Bill,

Try:

'===================
Public Sub Tester02()
Dim Rng As Range
Dim RngCol As Range
Dim WB As Workbook
Dim SH As Worksheet
Dim i As Long
Const PWORD As String = "YOUR PASSWORD"

Set WB = ActiveWorkbook '<<========== CHANGE
Set SH = WB.Sheets("Sheet1") '<<========== CHANGE

SH.Unprotect PWORD

SH.Cells.Locked = True

Application.ScreenUpdating = False
With SH.UsedRange
For i = 1 To .Columns(.Columns.Count).Column

On Error Resume Next
Set Rng = Columns(i).SpecialCells(xlBlanks)
On Error GoTo 0

If Not Rng Is Nothing Then
Rng.Cells.Locked = False
Rng.Cells.Interior.ColorIndex = 6 '<<======= CHANGE
End If
Next i
End With

SH.Protect PWORD

End Sub
'===================

---
Regards,
Norman



"Bill" wrote in message ...
Hi,

The spreadsheet has 2000 records and 30 columns. There are many blanks so
I just want to lock all the data that fill in cells and unlock for blank
cells for me to input the data. Is there a way to make the cell turn to
bold where I update the blank cell only.

Please help!!! Your help would be much apprecated.

Thanks.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Please Help!!!! If statement, lock and unlock cells

Hi Bill,

The line:

Dim RngCol As Range


can be deleted as it relates to a discarded variable.

The suggested code locks all populated cells on the specified worksheet. It
unlocks and highlights all blank cells.

It may be, however, that your intention is that highlighting should occur
dynamically in response to the population of previously blank cells. If this
is the case, please post back as the suggested code will require minor
amendment and an event procedure will need to be added


---
Regards,
Norman



"Norman Jones" wrote in message
...
Hi Bill,

Try:

'===================
Public Sub Tester02()
Dim Rng As Range
Dim RngCol As Range
Dim WB As Workbook
Dim SH As Worksheet
Dim i As Long
Const PWORD As String = "YOUR PASSWORD"

Set WB = ActiveWorkbook '<<========== CHANGE
Set SH = WB.Sheets("Sheet1") '<<========== CHANGE

SH.Unprotect PWORD

SH.Cells.Locked = True

Application.ScreenUpdating = False
With SH.UsedRange
For i = 1 To .Columns(.Columns.Count).Column

On Error Resume Next
Set Rng = Columns(i).SpecialCells(xlBlanks)
On Error GoTo 0

If Not Rng Is Nothing Then
Rng.Cells.Locked = False
Rng.Cells.Interior.ColorIndex = 6 '<<======= CHANGE
End If
Next i
End With

SH.Protect PWORD

End Sub
'===================

---
Regards,
Norman



"Bill" wrote in message
...
Hi,

The spreadsheet has 2000 records and 30 columns. There are many blanks
so I just want to lock all the data that fill in cells and unlock for
blank cells for me to input the data. Is there a way to make the cell
turn to bold where I update the blank cell only.

Please help!!! Your help would be much apprecated.

Thanks.





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
Using a Check Box to Lock/Unlock Cells [email protected] Excel Discussion (Misc queries) 3 April 27th 23 11:43 AM
Lock/Unlock cells BFife Excel Worksheet Functions 2 October 25th 06 03:20 PM
lock and unlock cells programatically call_Vishwa[_2_] Excel Programming 1 June 21st 05 07:55 PM
Lock and Unlock Cells Peter Excel Programming 5 January 29th 05 04:32 PM
Lock and Unlock cells using VBA Peter Excel Discussion (Misc queries) 1 January 29th 05 02:00 PM


All times are GMT +1. The time now is 10:34 PM.

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

About Us

"It's about Microsoft Excel"