Showing any changes on tab

tasander

Board Regular
Joined
Mar 6, 2009
Messages
67
Hi

I have a tab within a workbook where i want the user to copy a different spreadsheet into and then press a macro button to run some code, however after this button has been pressed i want this one tab to show any changes that have been made to it, i.e make the cell red or something just so i can keep track of manual adjustemnts.

Can anyone help??

Thanks
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

lenze

Legend
Joined
Feb 18, 2002
Messages
13,690
Hi and Welcome to the Board!!
For manual adjustments
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
With Target
   .Font.ColorIndex = 3
   .Font.Bold = True
End With
End Sub
You might, however, want to use a Comment to track changes

<a href="http://vbaexpress.com/kb/getarticle.php?kb_id=909"> Tracking Changes With Comments<a>

lenze
 
Upvote 0

tasander

Board Regular
Joined
Mar 6, 2009
Messages
67
Hi

Going back to this question, it works fine on all data but when the cell has #N/A or #VALUE! then it causes a break, do you know anyeay to get round this.

Thanks
 
Upvote 0

lenze

Legend
Joined
Feb 18, 2002
Messages
13,690
ADVERTISEMENT
Hi

Going back to this question, it works fine on all data but when the cell has #N/A or #VALUE! then it causes a break, do you know anyeay to get round this.

Thanks
I'm not following you. If you are entering data and using the WorkSheet_Change Event, how does the cell get a #N/A or #VALUE?

lenze
 
Upvote 0

tasander

Board Regular
Joined
Mar 6, 2009
Messages
67
Hi

sorry i'm not being too clear, i paste in a spreadsheet and then run a macro which at the end of the macro sets a variable to true so that the code you supplied knows to run whenever data is entered/changed.

The problem is that when the sheet is copied in, in the first place it usually has some erroneous data such as #N/A. i can do a search and replace on all these peior but would prefer some code to skip around these values.

Hope this makes more sense

Thanks
 
Upvote 0

lenze

Legend
Joined
Feb 18, 2002
Messages
13,690
ADVERTISEMENT
Post the code you currently are using. Also, the type of Data (Numbers?,Text? etc)
lenze
 
Upvote 0

tasander

Board Regular
Joined
Mar 6, 2009
Messages
67
Public preValue As Variant
Private Sub Worksheet_Change(ByVal Target As Range)


If Range("p1").Value = "Track" Then
If Target.Count > 1 Then Exit Sub
Target.ClearComments
Target.AddComment.Text Text:="Previous Value was " & preValue & Chr(10) & "Revised " & Format(Date, "mm-dd-yyyy") & Chr(10) & "By " & Environ("UserName")
With Target
.Font.ColorIndex = 7
.Font.Bold = True
End With

Else
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)


If Range("p1").Value = "Track" Then


If Target.Count > 1 Then Exit Sub
If Target = "" Then
preValue = "a blank"
Else: preValue = Target.Value
End If


Else
End If

End Sub

At the end of the macro i make cell P1 = "Track"

Everything works fine after that apart from when i click on a cell which contains: #VALUE! or #N/A (i.e calculations which are invalid or lookups which haven't worked)
 
Upvote 0

lenze

Legend
Joined
Feb 18, 2002
Messages
13,690
I don't understand the reason for P1="Track". Anyway, try adding this line at the beginning of both modules
Code:
If IsError(Target) Then Exit Sub

lenze
 
Upvote 0

tasander

Board Regular
Joined
Mar 6, 2009
Messages
67
Thanks, that works

The P1 reference is because i don't want the sheet to track changes all the time just some designated times
 
Upvote 0

Forum statistics

Threads
1,196,027
Messages
6,012,954
Members
441,740
Latest member
abaz21

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
Top