Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 846
Default BEFORE SheetSelectionChange

Thanks for taking the time to read my question.

I'm using Excel 2003 and I want to capture changes to a cell's value. How do
I know with VBA that a cells value has changed / updated?

I tried SheetSelectionChange, but it only gives me the value of the new cell.

Basically what I'm trying to do is if a cells value has gone from "" to
anything, lock the cell so it can't be edited.

Thanks,

Brad
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default BEFORE SheetSelectionChange

Cells are, by default, locked IF the sheet is protected. use a
worksheet_change event if UNlocked

Private Sub Worksheet_Change(ByVal Target As Range)
If Target < "" Then Target.Locked = True
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Brad" wrote in message
...
Thanks for taking the time to read my question.

I'm using Excel 2003 and I want to capture changes to a cell's value. How
do
I know with VBA that a cells value has changed / updated?

I tried SheetSelectionChange, but it only gives me the value of the new
cell.

Basically what I'm trying to do is if a cells value has gone from "" to
anything, lock the cell so it can't be edited.

Thanks,

Brad


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 846
Default BEFORE SheetSelectionChange

Here is what I have just just figured out.

Worksheet is protected.

Dim EnterCellVal As Variant
Dim EnterCellRow As Integer
Dim EnterCellCol As Integer


Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
If Cells(EnterCellRow, EnterCellCol).Value < EnterCellVal Then
ActiveSheet.Unprotect
Cells(EnterCellRow, EnterCellCol).Locked = True
ActiveSheet.Protect
End If
End Sub

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)
EnterCellVal = ActiveCell.Value
EnterCellRow = ActiveCell.Row
EnterCellCol = ActiveCell.Column
End Sub

Brad

"Don Guillett" wrote:

Cells are, by default, locked IF the sheet is protected. use a
worksheet_change event if UNlocked

Private Sub Worksheet_Change(ByVal Target As Range)
If Target < "" Then Target.Locked = True
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Brad" wrote in message
...
Thanks for taking the time to read my question.

I'm using Excel 2003 and I want to capture changes to a cell's value. How
do
I know with VBA that a cells value has changed / updated?

I tried SheetSelectionChange, but it only gives me the value of the new
cell.

Basically what I'm trying to do is if a cells value has gone from "" to
anything, lock the cell so it can't be edited.

Thanks,

Brad



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default BEFORE SheetSelectionChange

You are assuming that the cell is unlocked before you change it. Otherwise,
won't work. This will work also to place the existing value as public and
the worksheet_change will take over if a different value entered and it will
NOT fire with every calculation. ONLY when you change an UNlocked cell.

'============
Public oldvalue
Private Sub Workbook_SheetSelectionChange _
(ByVal Sh As Object, ByVal Target As Range)
oldvalue = Target.Value
End Sub
'=========
Private Sub Workbook_SheetChange _
(ByVal Sh As Object, ByVal Target As Range)
'MsgBox oldvalue
If Target < oldvalue Then
ActiveSheet.Unprotect
Target.Locked = True
ActiveSheet.Protect
End If
End Sub
'============


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Brad" wrote in message
...
Here is what I have just just figured out.

Worksheet is protected.

Dim EnterCellVal As Variant
Dim EnterCellRow As Integer
Dim EnterCellCol As Integer


Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
If Cells(EnterCellRow, EnterCellCol).Value < EnterCellVal Then
ActiveSheet.Unprotect
Cells(EnterCellRow, EnterCellCol).Locked = True
ActiveSheet.Protect
End If
End Sub

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)
EnterCellVal = ActiveCell.Value
EnterCellRow = ActiveCell.Row
EnterCellCol = ActiveCell.Column
End Sub

Brad

"Don Guillett" wrote:

Cells are, by default, locked IF the sheet is protected. use a
worksheet_change event if UNlocked

Private Sub Worksheet_Change(ByVal Target As Range)
If Target < "" Then Target.Locked = True
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Brad" wrote in message
...
Thanks for taking the time to read my question.

I'm using Excel 2003 and I want to capture changes to a cell's value.
How
do
I know with VBA that a cells value has changed / updated?

I tried SheetSelectionChange, but it only gives me the value of the new
cell.

Basically what I'm trying to do is if a cells value has gone from "" to
anything, lock the cell so it can't be edited.

Thanks,

Brad




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
SheetSelectionChange when modal form is shown Alex Simachov Excel Programming 0 January 21st 08 09:41 PM
SheetSelectionChange Geoff Excel Programming 7 November 6th 06 01:55 PM
SheetSelectionChange Event find out previosly selected cell Anton Sommer Excel Programming 2 August 8th 05 10:04 PM
SheetSelectionChange Frank Kabel Excel Programming 0 April 26th 04 04:28 PM
SheetSelectionChange Target size Limitation? Guillaume E. Excel Programming 1 September 27th 03 04:34 PM


All times are GMT +1. The time now is 04:56 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"