Worksheet 'Change' Event: Show Which Rows Of Data Have Been Changed By Incrementing A Revision Attribute
May 13, 2009
I want to show which rows of data have been changed by incrementing a revision attribute. For example, if a user changes the contents of a cell anywhere between rows 2 and 13 and col 1 and 9 then the revision attribute in col 10 would increment from 1 to 2 (for the affected row). If another change affects the same row then the rev attribute would increment to 3, and so forth. I don't care which cell was changed only that something on that row was touched.
I thought the CHANGE event was a dead ringer for triggering some VBA code to control this but, since part of the change event code writes the revision value, this triggers another CHANGE event causing an endless loop until something (??) kicks in and stops it after 220 iterations. Is there a way to inhibit the change event just prior to updating the cell containing the version attribute?
Rather than post the code here I have submitted the workbook that includes the whole setup and code. I should also mention I looked at all the other worksheet events and I do not see any "triggers" that would fire each time a cell content is changed. As a side note, is there a way to step into the code of a change event? F8 does nothing.
View 3 Replies
ADVERTISEMENT
Jul 16, 2014
I need to use the Worksheet Change event in a particular sheet in a specified column which works fine if the data is already there in the sheet and then changed however,the data is in this sheet is actually a Sub-Set of a Main sheet i.e certain filtered records are being copied from Main Sheet and then copied to this IBSL Sheet.
After the data is copied I have to check each record manually and then categorize each record as Fresh , Rebooked , Cancelled , Tranch or On-Hold.....These 4 criterias are added in the Column 38 and the same thing has to be repeated in the column 40 , so when i change the data in the column 38 the same category has to be updated in the same row in the column 40..
But the problem is that the data is first copied from the Main Data Sheet into the IBSL Sheet using a Macro so then this even t gets fired and goes in the DEBUG MODE...
I need this to happen when i change the category manually..I am adding data validation at the same time while copying the data in to the TEMP sheet.
So what can be done to achieve..
View 7 Replies
View Related
Oct 23, 2008
my problem involves displaying rows that meet certain ‘criteria’, on a separate worksheet, in real time. The criteria will be determined by a selection made from a dropdown list in the row in question.
ILLUSTRATION: Let us say (for example) that I am dealing with a worksheet for MEN’S DATA. Each man’s data will be on a separate row. On each row, one of the cells has a dropdown list having 2 options, SHORT and TALL. I have a separate report worksheet for TALL men. I mean, I want every row for which I select the TALL option, to be copied to my TALL report worksheet. I want the selection of the TALL option to be a kind of trigger that promptly copies the row to the TALL worksheet, once I make the selection from the dropdown list.
View 9 Replies
View Related
Dec 4, 2006
Private Sub Worksheet_Change(ByVal Target As Range)
With Target.Cells(1, 1)
If Not Intersect(.Cells, Range("b3:b6")) Is Nothing Then
Range("b7") = "Not Found"
For i = 3 To 6: txt = txt & Cells(i, "b").Value & "_": Next
For Each r In Range("m3", Cells(3, Columns.Count).End(xlToLeft))
For i = 0 To 3: txt2 = txt2 & r.Offset(i).Value & "_": Next
If txt = txt2 Then
Range("b7").Value = r.Offset(4).Value
Exit For
End If
txt2 = ""
Next
ElseIf Not Intersect(.Cells, Range("b16:b19")) Is Nothing Then
Range("b20") = "Not Found".....................
I'm working with this code right now. The problem is the macro will only work if i type the numbers manually. if the values are retrieved from a combobox, the code above down not work as it cannot read the values.
View 9 Replies
View Related
Mar 27, 2009
Is there a way to write a Worksheet_SelectionChange (ByVal Target As Range) event in module after creating a sheet in VBA? I constantly delete a sheet, then repopulate it with a new one that is empty, but I need to add some code that happens if they should change a particular cell. It worked when I ran it on a worksheet without refreshing, but as soon as I cleared and repopulated the sheet, it was gone. Is there a way to preserve this?
View 9 Replies
View Related
Feb 11, 2014
I am trying to have one cell (G5) populate with a timestamp when a change is made to any cells in a range (some are merged). The code below worked for a second, until it didn't.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("F8:G33")) Is Nothing Then Exit Sub
Range("G5").Value = Now()
End Sub
*Getting a yellow arrow by the row starting with Range("G5")
View 6 Replies
View Related
Jun 17, 2009
an event macro to change the font colour of a cell whose value changes as a result of a calculation.
View 9 Replies
View Related
Jul 21, 2009
Attached is book in which, when a choice is selected from Drop Down list in ColumnF the macro has to do the need.
When the macro was written it was working well. But when I tried to change it as a Worksheet_SelectionChange event nothing is happenning even though a choice is selected from drop down list.
View 4 Replies
View Related
Dec 6, 2011
Basically the situation I have is Sheet2 has many references to cells in Sheet1. Sheet2 is for all intents and purposes a kind of nicely formatted report form, and Sheet1 is the input form.
My ultimate goal is to automatically resize row heights on Sheet2 when cell contents change on Sheet2.
Using a worksheet_change event isn't working I presume because it doesn't see the formula output change as a worksheet change, the worksheet_change is firing only when the input is changed in Sheet1.
how can I capture these formula output changes on Sheet2 (triggered from input on Sheet1) OR is there a way of making a particular sheets rows always adjust in height to best fit?
View 5 Replies
View Related
Jun 12, 2007
In cell A1, I have the month number (eg, 1, 2, 3,). The month number reflects current month and will automatically change with every month. For example, right now it’s 6, next month it will automatically change to 7. Each two columns in Range A10:X20 represents the data from January to December. I want to use a worksheet event to change the background of the current month two columns in the range to yellow color and the two columns in the range will be visible when I activate this sheet.
View 3 Replies
View Related
Jan 10, 2009
looking to only allow a check ("x") in a column for a reconcile - type worksheet. Am I close?
Private Sub Worksheet_Change(ByVal Target As Range)
'Data protection. Only allow "x" in the "cleared" column. If anything else is entered, a message box informs the user
'and the cell contents are cleared.
Dim val As Variant
Dim msg As String
If ActiveCell.Value "x" Then
msg = "You can only enter an X in the cleared column."
ActiveCell.ClearContents
End If
End Sub
View 9 Replies
View Related
Feb 7, 2014
I am trying to run the below code whenever the result of cells (22,x) changes. Cells (22,x) contains a formula.
[Code] .....
View 2 Replies
View Related
May 28, 2009
trying to get a worksheet change event to work. Basically the code below calls the time_start procedure when cell J16 downwards is selected.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row > 15 And Target.Column = 10 Then
Call time_start
Else
End If
End Sub
However, I am lost from here on....Let me try and explain what it is I am trying to do. This seems so simple if you know how. Each time that the word "Completed" is entered in to a cell from J16 onwards, the cell two columns to the right on the same row is selected and the current date is entered.
If the word "Completed" is deleted, I want the date on that row to be deleted.
I would also like the choices "Completed" and a blank cell to be given in a validation list via a dropdown if possible to avoid occurances of "Complete" etc and mis-spellings but I understand that a bug may stop me from using this functionality. I am running Excel 2002 on a Windows XP Professional OS.
View 9 Replies
View Related
May 7, 2013
I have the below vba and would like to have the '''event calculated ''' on any event on the worksheet. Right now it only update if updating the val1 thru val6 cells. How can i get the worksheet to update on any event or change on the sheet?
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
fr = Range("a65536").End(xlUp).Row
Set Rng = Range("a2" & ":n" & fr)
If Intersect(Target, Rng) Is Nothing Then Exit Sub
[Code] .......
View 2 Replies
View Related
Mar 6, 2007
I have looked at the threads concerning cell change events but cannot find a solution to my situation. I have a worksheet with a cell using a validation list. I wish to exicute a procedure whenever the dropdown list is changed in that one cell. Everything I have seen in the Worksheet event threads is evaluating the contents of a cell and I am attempting to exicute if the cell changes.
View 2 Replies
View Related
Aug 22, 2007
I have a spreadsheet with a table of values in range E5 to T158.
A macro populates the table by looking up values on other sheets in the book. If the macro finds a value in the lookup for Row 7 of any column (ie E7,F7...T7) it populates the rest of the column with that value (E7 value gets pasted to E8:E158) THEN it protects the cells it pasted (E8:E158).
If the macro does NOT find a value for row 7, it simply skips it, leaving it blank, and continues to row 8 until it reaches row 158 of each column E to T.
I want to give the user flexibility with these values. So if the user either deletes E7 or changes the value of the contents in E7, I want to unprotect the cells of rows 8 to 158 for that column.
I have created a
Private Sub Worksheet_Change(ByVal Target As Range)
in the private module for that sheet below. I thought it was working but it isn't doing anything when I change or delete the value in Cell E7 for example. Please help!
Private Sub Worksheet_Change(ByVal Target As Range)
'Do nothing if more than one cell is changed
If Target.Cells.count > 1 Then Exit Sub 'Or IsEmpty(Target)
View 5 Replies
View Related
Nov 22, 2011
I'm trying to create a worksheet change event macro that will change the colour of the cell when you update the value in that cell.
I have column C with 140 rows and when one of the cells in the column is changed by the user, I need the same cell to highlight in yellow. The highlight would then be removed once the user has acted on the change in the value, and that'll be done in another macro.
I understand I need a worksheet change event macro in the specific sheet and need the following code for yellow:
Code:
.Interior.Color = RGB(255,255,0)
, but any further I get stuck as it involves 'target addresses'
View 2 Replies
View Related
Oct 1, 2013
combine two Worksheet Change event macros into the one macro? The macros are listed below.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)On Error GoTo exitHandler
Dim rngDV As Range
Dim lRow As Long
Dim lCol As Long
[Code]...
exitHandler:
Application.EnableEvents = True
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("O:O")) Is Nothing Then
Application.EnableEvents = False
[Code]...
View 7 Replies
View Related
Nov 30, 2006
I have the following code that should pop up a message when column E is left blank when "other" is typed into column D. But I cannot get it to work.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range, LastRow As Range
Dim x As Integer
If Target.Count > 1 Then Exit Sub
Set rng = Range("F:F")
If Intersect(Target, rng) Is Nothing Then Exit Sub
If Target = "" Then
For x = 1 To 5000
If Cells(x, 4).Value = "Other" And Cells(x, 5).Value = "" Then
Answer = MsgBox("If other, please state", vbOKCancel, "CONFIRMATION")
End If
Next x
End If
End Sub
View 9 Replies
View Related
Mar 28, 2007
I have the following code that 'sort of' works.
Private Sub Worksheet_Change(ByVal Target As Range) ...
View 9 Replies
View Related
Jul 31, 2008
In Col D of my spreadsheet, I have a list of security codes, in this list there is a security code "all", i need a macro that will add 1 to the code, so it reads "all1", now i need the macro to run as soon as new data is pasted to sheet "Lending", the ranges in Col D do change on a daily basis therefore cell reference for security codes is not fixed.
Can this be achieved? ............
View 9 Replies
View Related
Mar 5, 2009
I am using Excel 2007, and I have a macro (that is working) that I would like to run whenever there has been a new selection in a dropdown list on my worksheet. I have done this many times before in other workbooks, and I have always used:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub
To my knowledge this should trigger the macro when the dropdown selection changes. However, this time it is not working. The macro runs fine manually, but it does not run when the dropdown selection changes.
View 9 Replies
View Related
Apr 25, 2009
This is the code on the Worsheet Change event.
Private Sub Worksheet_Change(ByVal Target As Range)
'Define the RMAs range and count the RMA ships. Do the rest of the math based on this calculation.
Dim intRMACol As Integer, EndRow As Integer, intRMAShips As Integer, LastCol As Integer
Dim rngRMAs As Range, rngHome As Range, sht As Worksheet
Set sht = ActiveWorkbook.ActiveSheet
Set rngHome = Cells(1, 1)
rngHome.Activate
EndRow = Range("A" & Rows.Count).End(xlUp).Row
intRMACol = Cells.Find(What:="RMA#", After:=[A1], SearchOrder:=xlByColumns, SearchDirection:=xlNext).Column
Set rngRMAs = rngHome.Offset(1, intRMACol - 1).Resize(EndRow, 1)
rngRMAs.Name = "RMAs"
rngHome.Offset(1, LastCol + 1).Formula = "=COUNTA(RMAs)"
intRMAShips = rngHome.Offset(1, LastCol + 1).Value
rngHome.Offset(1, LastCol).Formula = "=SUM((" & EndRow & " - 1) - " & intRMAShips & ")"
rngHome.Offset(1, LastCol + 2).FormulaR1C1 = "=SUM(RC[-2] : RC[-1])"
End Sub
I keep getting stuck when trying to set the intRMACol variable. I have used the code all over the place, but only in Modules, never on a worksheet event. EndRow, the variable right above, sets correctly so I don't get it.
Also, do I have to define the Target variable? Am I going about this the right way? I basically want three formulas to calculate when any change is made on the worksheet.
View 9 Replies
View Related
Nov 9, 2009
I'm trying to insert a worksheet change event using VBA. I have this sample code from here -
http://www.cpearson.com/Excel/vbe.aspx
Sub CreateEventProcedure()
Dim VBProj As VBIDE.VBProject
Dim VBComp As VBIDE.VBComponent
Dim CodeMod As VBIDE.CodeModule
Dim LineNum As Long
Const DQUOTE = """" ' one " character
Set VBProj = ActiveWorkbook.VBProject
Set VBComp = VBProj.VBComponents("ThisWorkbook")
Set CodeMod = VBComp.CodeModule...................
View 9 Replies
View Related
Aug 4, 2006
I have this code working fine. It applies conditional formating to two rows ((K3:K65) and (J3:J65)) and checks when a value changes in row B to reaplpy the formatting. I'd like to had add more columns to it. It would have apply the same conditonal formatting on rows ((O3:O65) and (P3:P65)) but when a value changes in row (N3:N65)
So basically, I want to keep the first working part of the code and have it to check at more rows with a different reference for the conditionnal formatting.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Dim rngJ As Range
If Target.Count > 1 Then Exit Sub
Set rng = Union(Range("B3:B65"), Range("J3:J65"))
If Intersect(Target, rng) Is Nothing Then Exit Sub
Set rngJ = Range("K" & Target.Row)
Select Case rngJ.Value
Case ""
rngJ.Interior.ColorIndex = xlNone
rngJ.Offset(0, -1).Interior.ColorIndex = xlNone
Case Is >= 20.............................
View 2 Replies
View Related
Aug 29, 2006
I am trying to make a macro run automatically based on info entered in a cell. The problem is I need this code on at least three separate sheets in the work book. It doesent work when I try to use the same basic code. The code I am using is below.
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim lLastRow As Long
Dim rgArea As Range, rgCell As Range
Dim COL_B As Integer
COL_B = 2
Dim COL_X As Integer
COL_X = 24
Dim ROW_FIRST As Long
ROW_FIRST = 5
' Find the last row of date in the "Approved" worksheet
lLastRow = FindLastRow(SZ_WS_APPROVED, COL_B)
' Set a reference to the changed cells in column X
Set Target = Intersect(Target, Range(Cells(ROW_FIRST, COL_X), Cells(lLastRow, COL_X))).........................
View 5 Replies
View Related
Aug 31, 2006
Private Sub Worksheet_Change(ByVal Target As Excel. Range)
Dim S As String, X As Variant, n As Long
If Target.Column <> 3 Or Target.Cells.Count <> 1 Then Exit Sub
If IsEmpty(Target) Then Exit Sub
S = Target.Text
On Error Goto Reset
n = Application.Substitute(S, "-", "")
On Error Goto Reset
Application.EnableEvents = False
X = Application.Match(n, Workbooks("Database.xls"). Sheets("Products").Range("B1:B14000"), 0)
If IsNumeric(X) Then
Target.Offset(0, -1) = Workbooks("Database.xls").Sheets("Products").Cells(X, 1).Value
Else............................
But each time i add it in, it ether's turns off the second statement and second works or vice versa. How can make both codes work at the same time without conflicting each other.
View 3 Replies
View Related
Sep 1, 2006
I am trying to do a conditional format of 0 to 2 is red, 3 to 4 is yellow and 5 is green. However I also need to have a cell that is blank to remain white and this is the part I am having problems with.
I found the following code since I cannot use the standard conditional formating in excel since it needs 4 conditions.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim icolor As Integer
If Not Intersect(Target, Range("H3:H12")) Is Nothing Then
Select Case Target
Case 0 To 2
icolor = 3
Case 3 To 4
icolor = 6
Case 5
View 7 Replies
View Related
Nov 2, 2006
Is it possible for a combo box selection, linked to a cell on the same sheet to fire a worksheet change event? I can't seem to find a way to do it.
View 3 Replies
View Related
May 13, 2007
This is my
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("D6:D6000")) Is Nothing Or Intersect(Target, Range("D6:D6000")) = "" Then
If Intersect(Target, Range("F6:F6000")) Is Nothing Or Intersect(Target, Range("F6:F3000")) = "" Then
If Intersect(Target, Range("I6:I6000")) Is Nothing Or Intersect(Target, Range("I6:I6000")) = "" Then
Exit Sub
Else
Do Something......
End If
End If
End If
End Sub
when excution comes to this line
If Intersect(Target, Range("D6:D6000")) Is Nothing Or Intersect(Target, Range("D6:D6000")) = "" Then
a run time error (91) appears, it tells object variable or with block variable not set.
View 9 Replies
View Related