Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 127
Default autofilter and adding comments

Dear experts,
I have a code that, whenever you change a cell in a worksheet, adds a
comment with the username and date on that cell.
Now, if you drag the cell where you have made the input to copy it on other
cells, and the autofilter is on, the code does not make the difference
between filtered and non filtered cells!
That's to say, if you just have rows 2 and 5 autofiltered and drag the cell
from row 2 to 5, the cell content will be correctly copied, but the comments
will be added in every cell from row 2 to 5.

Is there any way I can modify this behaviour?
Many thanks in advance for your help,
Best regards,
Valeria

My code is:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim vvvrange As Range
Dim cell As Object
Set vvvrange = Range("Comment_Input") '$T$1:$W$400
Application.EnableEvents = False
On Error Resume Next
For Each cell In Target
If Union(cell, vvvrange).Address = vvvrange.Address Then
cell.Comment.Delete
cell.AddComment
cell.Comment.Visible = False
cell.Comment.Text Text:=Application.UserName & Chr(10) & Format(Date,
"DD-MMM-YYYY")
cell.Comment.Shape.TextFrame.AutoSize = True
End If
Next cell
On Error GoTo 0
Application.EnableEvents = True
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default autofilter and adding comments

Possibly:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim vvvrange As Range
Dim cell As Object
Set vvvrange = Range("Comment_Input") '$T$1:$W$400
Application.EnableEvents = False
On Error Resume Next
For Each cell In Target
If Union(cell, vvvrange).Address = vvvrange.Address Then
if cell.EntireRow.Visible = True then
cell.Comment.Delete
cell.AddComment
cell.Comment.Visible = False
cell.Comment.Text Text:=Application.UserName & _
Chr(10) & Format(Date, "DD-MMM-YYYY")
cell.Comment.Shape.TextFrame.AutoSize = True
end if
End If
Next cell
On Error GoTo 0
Application.EnableEvents = True
End Sub

--
Regards,
Tom Ogilvy

"Valeria" wrote in message
...
Dear experts,
I have a code that, whenever you change a cell in a worksheet, adds a
comment with the username and date on that cell.
Now, if you drag the cell where you have made the input to copy it on

other
cells, and the autofilter is on, the code does not make the difference
between filtered and non filtered cells!
That's to say, if you just have rows 2 and 5 autofiltered and drag the

cell
from row 2 to 5, the cell content will be correctly copied, but the

comments
will be added in every cell from row 2 to 5.

Is there any way I can modify this behaviour?
Many thanks in advance for your help,
Best regards,
Valeria

My code is:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim vvvrange As Range
Dim cell As Object
Set vvvrange = Range("Comment_Input") '$T$1:$W$400
Application.EnableEvents = False
On Error Resume Next
For Each cell In Target
If Union(cell, vvvrange).Address = vvvrange.Address Then
cell.Comment.Delete
cell.AddComment
cell.Comment.Visible = False
cell.Comment.Text Text:=Application.UserName & Chr(10) & Format(Date,
"DD-MMM-YYYY")
cell.Comment.Shape.TextFrame.AutoSize = True
End If
Next cell
On Error GoTo 0
Application.EnableEvents = True
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 127
Default autofilter and adding comments

Hi Tom,
I get the warning in the watch window that <Object doesn't support this
property or method, and Excel ignores the line...
What should I change?
Many thanks!
Best regards,
Valeria

"Tom Ogilvy" wrote:

Possibly:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim vvvrange As Range
Dim cell As Object
Set vvvrange = Range("Comment_Input") '$T$1:$W$400
Application.EnableEvents = False
On Error Resume Next
For Each cell In Target
If Union(cell, vvvrange).Address = vvvrange.Address Then
if cell.EntireRow.Visible = True then
cell.Comment.Delete
cell.AddComment
cell.Comment.Visible = False
cell.Comment.Text Text:=Application.UserName & _
Chr(10) & Format(Date, "DD-MMM-YYYY")
cell.Comment.Shape.TextFrame.AutoSize = True
end if
End If
Next cell
On Error GoTo 0
Application.EnableEvents = True
End Sub

--
Regards,
Tom Ogilvy

"Valeria" wrote in message
...
Dear experts,
I have a code that, whenever you change a cell in a worksheet, adds a
comment with the username and date on that cell.
Now, if you drag the cell where you have made the input to copy it on

other
cells, and the autofilter is on, the code does not make the difference
between filtered and non filtered cells!
That's to say, if you just have rows 2 and 5 autofiltered and drag the

cell
from row 2 to 5, the cell content will be correctly copied, but the

comments
will be added in every cell from row 2 to 5.

Is there any way I can modify this behaviour?
Many thanks in advance for your help,
Best regards,
Valeria

My code is:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim vvvrange As Range
Dim cell As Object
Set vvvrange = Range("Comment_Input") '$T$1:$W$400
Application.EnableEvents = False
On Error Resume Next
For Each cell In Target
If Union(cell, vvvrange).Address = vvvrange.Address Then
cell.Comment.Delete
cell.AddComment
cell.Comment.Visible = False
cell.Comment.Text Text:=Application.UserName & Chr(10) & Format(Date,
"DD-MMM-YYYY")
cell.Comment.Shape.TextFrame.AutoSize = True
End If
Next cell
On Error GoTo 0
Application.EnableEvents = True
End Sub




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default autofilter and adding comments

my fault

if cell.EntireRow.Visible = True then

should be

if cell.EntireRow.Hidden = False then

--
Regards,
Tom Ogilvy


"Valeria" wrote in message
...
Hi Tom,
I get the warning in the watch window that <Object doesn't support this
property or method, and Excel ignores the line...
What should I change?
Many thanks!
Best regards,
Valeria

"Tom Ogilvy" wrote:

Possibly:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim vvvrange As Range
Dim cell As Object
Set vvvrange = Range("Comment_Input") '$T$1:$W$400
Application.EnableEvents = False
On Error Resume Next
For Each cell In Target
If Union(cell, vvvrange).Address = vvvrange.Address Then
if cell.EntireRow.Visible = True then
cell.Comment.Delete
cell.AddComment
cell.Comment.Visible = False
cell.Comment.Text Text:=Application.UserName & _
Chr(10) & Format(Date, "DD-MMM-YYYY")
cell.Comment.Shape.TextFrame.AutoSize = True
end if
End If
Next cell
On Error GoTo 0
Application.EnableEvents = True
End Sub

--
Regards,
Tom Ogilvy

"Valeria" wrote in message
...
Dear experts,
I have a code that, whenever you change a cell in a worksheet, adds a
comment with the username and date on that cell.
Now, if you drag the cell where you have made the input to copy it on

other
cells, and the autofilter is on, the code does not make the difference
between filtered and non filtered cells!
That's to say, if you just have rows 2 and 5 autofiltered and drag the

cell
from row 2 to 5, the cell content will be correctly copied, but the

comments
will be added in every cell from row 2 to 5.

Is there any way I can modify this behaviour?
Many thanks in advance for your help,
Best regards,
Valeria

My code is:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim vvvrange As Range
Dim cell As Object
Set vvvrange = Range("Comment_Input") '$T$1:$W$400
Application.EnableEvents = False
On Error Resume Next
For Each cell In Target
If Union(cell, vvvrange).Address = vvvrange.Address Then
cell.Comment.Delete
cell.AddComment
cell.Comment.Visible = False
cell.Comment.Text Text:=Application.UserName & Chr(10) & Format(Date,
"DD-MMM-YYYY")
cell.Comment.Shape.TextFrame.AutoSize = True
End If
Next cell
On Error GoTo 0
Application.EnableEvents = True
End Sub






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 127
Default autofilter and adding comments

Hi Tom,
it works wonderfully, thank you very much!
Best regards,
Valeria

"Tom Ogilvy" wrote:

my fault

if cell.EntireRow.Visible = True then

should be

if cell.EntireRow.Hidden = False then

--
Regards,
Tom Ogilvy


"Valeria" wrote in message
...
Hi Tom,
I get the warning in the watch window that <Object doesn't support this
property or method, and Excel ignores the line...
What should I change?
Many thanks!
Best regards,
Valeria

"Tom Ogilvy" wrote:

Possibly:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim vvvrange As Range
Dim cell As Object
Set vvvrange = Range("Comment_Input") '$T$1:$W$400
Application.EnableEvents = False
On Error Resume Next
For Each cell In Target
If Union(cell, vvvrange).Address = vvvrange.Address Then
if cell.EntireRow.Visible = True then
cell.Comment.Delete
cell.AddComment
cell.Comment.Visible = False
cell.Comment.Text Text:=Application.UserName & _
Chr(10) & Format(Date, "DD-MMM-YYYY")
cell.Comment.Shape.TextFrame.AutoSize = True
end if
End If
Next cell
On Error GoTo 0
Application.EnableEvents = True
End Sub

--
Regards,
Tom Ogilvy

"Valeria" wrote in message
...
Dear experts,
I have a code that, whenever you change a cell in a worksheet, adds a
comment with the username and date on that cell.
Now, if you drag the cell where you have made the input to copy it on
other
cells, and the autofilter is on, the code does not make the difference
between filtered and non filtered cells!
That's to say, if you just have rows 2 and 5 autofiltered and drag the
cell
from row 2 to 5, the cell content will be correctly copied, but the
comments
will be added in every cell from row 2 to 5.

Is there any way I can modify this behaviour?
Many thanks in advance for your help,
Best regards,
Valeria

My code is:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim vvvrange As Range
Dim cell As Object
Set vvvrange = Range("Comment_Input") '$T$1:$W$400
Application.EnableEvents = False
On Error Resume Next
For Each cell In Target
If Union(cell, vvvrange).Address = vvvrange.Address Then
cell.Comment.Delete
cell.AddComment
cell.Comment.Visible = False
cell.Comment.Text Text:=Application.UserName & Chr(10) & Format(Date,
"DD-MMM-YYYY")
cell.Comment.Shape.TextFrame.AutoSize = True
End If
Next cell
On Error GoTo 0
Application.EnableEvents = True
End Sub






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
adding up COMMENTS pcor New Users to Excel 8 July 19th 07 03:30 PM
Comments in protected cells with AutoFilter switched on TishyMouse Excel Discussion (Misc queries) 3 May 30th 07 01:34 PM
Adding Comments to a Cell Edward O'Brien Excel Discussion (Misc queries) 3 June 8th 05 12:52 PM
Adding comments Karla Charts and Charting in Excel 2 June 3rd 05 09:04 PM
Adding Comments Kim Excel Discussion (Misc queries) 4 March 17th 05 01:57 PM


All times are GMT +1. The time now is 11:56 AM.

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"