getting previous cell values in excel sheets 
Author Message
 getting previous cell values in excel sheets

hi all,

when we enter a value in a cell, the worksheet_change
event is invoked in it's VBA code.

if we want to validate the new value entered and restore
it back to the original value, if the new value is
invalid how do we do it?

thanks,
niraj.



Mon, 11 Jul 2005 13:30:32 GMT  
 getting previous cell values in excel sheets
Hi niraj,

Y'd be looking for somehting like:

Dim OldVal As Variant

'validate change in cell, in this case, it
'restores original value of target if users input 999
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    If Target = "999" Then Target = OldVal
End Sub

'store value of new selection
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
    OldVal = Target
End Sub

Krgrds,
Perry



Quote:
> hi all,

> when we enter a value in a cell, the worksheet_change
> event is invoked in it's vba code.

> if we want to validate the new value entered and restore
> it back to the original value, if the new value is
> invalid how do we do it?

> thanks,
> niraj.



Tue, 12 Jul 2005 07:17:04 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Getting values of Excel cells from word VBA

2. Getting values from Excel cells using VB5

3. Rows and cells in a excel sheet

4. Getting the list of Excel Sheet Names using VBA

5. Getting the RIGHT Excel sheet with OLE automation - AddOLEObj

6. getting the name of the active sheet (Excel)

7. how getting data from EXCEL.sheets

8. VB 3.0 PRO/EXCEL/DDE Getting info from different sheets

9. Getting excel sheet names with DAO

10. getting sheet name in excel

11. Getting excel sheet names with DAO

12. Getting the value of a Cell in a DataGrid

 

 
Powered by phpBB® Forum Software