building comments from text cells

M

Michael.Tarnowski

Hi community,
I have an Excel application where I append a new line (by a VBA macro
assign to a button) from a kind of template.
Sheet A is the application, sheet B contains the "row template":

Sheet B:
cells in row 08: each cells is a comment text
09: each cell is a header description
10: each cell contains a formula

Row 09 in sheet A is the table's heading defined in sheet B, 09. The
application uses row 03 of Sheet B to append a new line in sheet A.
What I want to achieve is that all comments (sheet B, row 8) are Excel
real comments of the cells of sheet A, row 9.
Any ideas?
 
S

Shane Devenshire

You can try copying the row of comments and choosing the Edit, Paste Special,
Comments command to paste the comments into the other row.
 
G

Gord Dibben

Assuming cells in row 9 of Sheet B are linked to Sheet A

This macro will place whatever is in Sheet B A9:M9 into Comments in A8:M8

Is that what you want?

Sub Comment_Add()
Dim cmt As Comment
Dim r As Range
For Each r In Sheets("Sheet2").Range("A8:M8") 'adjust to suit
Set cmt = r.Comment
If cmt Is Nothing Then
Set cmt = r.AddComment
cmt.Text Text:=r.Offset(1, 0).Text
End If
Next r
End Sub

Comments will not update if values are changed.

Do you need something dynamic?


Gord Dibben MS Excel MVP
 
M

Michael.Tarnowski

Assuming cells in row 9 of Sheet B are linked to Sheet A

This macro will place whatever is in Sheet B A9:M9 into Comments in A8:M8

Is that what you want?

Sub Comment_Add()
Dim cmt As Comment
Dim r As Range
For Each r In Sheets("Sheet2").Range("A8:M8") 'adjust to suit
Set cmt = r.Comment
If cmt Is Nothing Then
Set cmt = r.AddComment
cmt.Text Text:=r.Offset(1, 0).Text
End If
Next r
End Sub

Comments will not update if values are changed.

Do you need something dynamic?

Gord Dibben MS Excel MVP

Gord you got it - thats exactly what I'am looking for. Dynamic updates
would be great!
Thanks Michael
 
G

Gord Dibben

A little late getting back to you.

Try this revision which updates the Comments' contents.

Sub Comment_Add()
Dim addtext As String
Dim cmt As Comment
Dim rng As Range
Set rng = Sheets("Sheet2").Range("A8:M8")
For Each cell In rng
Set cmt = cell.Comment
addtext = cell.Offset(1, 0).Text
If cmt Is Nothing Then
Set cmt = cell.AddComment
cmt.Text Text:=addtext
Else
cmt.Text Text:=addtext
End If
Next cell
End Sub

To be truly dynamic, you could call it from some type of worksheet event
like calculate.

Private Sub Worksheet_Calculate()
Comment_Add
End Sub

The event code would be inserted into the Sheet2 module and would trigger
when you made a change in any of the row 9 source cells in Sheet1.


Gord
 
M

Michael.Tarnowski

A little late getting back to you.

Try this revision which updates the Comments' contents.

Sub Comment_Add()
Dim addtext As String
Dim cmt As Comment
Dim rng As Range
Set rng = Sheets("Sheet2").Range("A8:M8")
For Each cell In rng
Set cmt = cell.Comment
addtext = cell.Offset(1, 0).Text
If cmt Is Nothing Then
Set cmt = cell.AddComment
cmt.Text Text:=addtext
Else
cmt.Text Text:=addtext
End If
Next cell
End Sub

To be truly dynamic, you could call it from some type of worksheet event
like calculate.

Private Sub Worksheet_Calculate()
Comment_Add
End Sub

The event code would be inserted into the Sheet2 module and would trigger
when you made a change in any of the row 9 source cells in Sheet1.

Gord

Gord,
thank you for the extention to a dynamic version. It works - but in
the wrong direction ;-(
I assume I mixed something up so you did not get the point.
To clarify my intention:

Sheet "Configuration" helds in A8:AF8 the comment text - since this
row may expands I defined a dynamic range "dynComments" for this
In sheet "ActionItemList" the cells in row a9:AF9 shall get the
comment of each cell in dynComments.

Your code assigns to all cells in "Configuration" (dynComments) the
comments of cells in range dynComments by change of sheet
"ActionItemList" - in your posting Sheet2.

How should I change your code?
Thanks Michael
 
M

Michael.Tarnowski

A little late getting back to you.

Try this revision which updates the Comments' contents.

Sub Comment_Add()
Dim addtext As String
Dim cmt As Comment
Dim rng As Range
Set rng = Sheets("Sheet2").Range("A8:M8")
For Each cell In rng
Set cmt = cell.Comment
addtext = cell.Offset(1, 0).Text
If cmt Is Nothing Then
Set cmt = cell.AddComment
cmt.Text Text:=addtext
Else
cmt.Text Text:=addtext
End If
Next cell
End Sub

To be truly dynamic, you could call it from some type of worksheet event
like calculate.

Private Sub Worksheet_Calculate()
Comment_Add
End Sub

The event code would be inserted into the Sheet2 module and would trigger
when you made a change in any of the row 9 source cells in Sheet1.

Gord

Gord,
thank you for the extention to a dynamic version. It works - but in
the wrong direction ;-(
I assume I mixed something up so you did not get the point.
To clarify my intention:

Sheet "Configuration" helds in A8:AF8 the comment text - since this
row may expands I defined a dynamic range "dynComments" for this
In sheet "ActionItemList" the cells in row a9:AF9 shall get the
comment of each cell in dynComments.

Your code assigns to all cells in "Configuration" (dynComments) the
comments of cells in range dynComments by change of sheet
"ActionItemList" - in your posting Sheet2.

How should I change your code?
Thanks Michael
 
M

Michael.Tarnowski

A little late getting back to you.

Try this revision which updates the Comments' contents.

Sub Comment_Add()
Dim addtext As String
Dim cmt As Comment
Dim rng As Range
Set rng = Sheets("Sheet2").Range("A8:M8")
For Each cell In rng
Set cmt = cell.Comment
addtext = cell.Offset(1, 0).Text
If cmt Is Nothing Then
Set cmt = cell.AddComment
cmt.Text Text:=addtext
Else
cmt.Text Text:=addtext
End If
Next cell
End Sub

To be truly dynamic, you could call it from some type of worksheet event
like calculate.

Private Sub Worksheet_Calculate()
Comment_Add
End Sub

The event code would be inserted into the Sheet2 module and would trigger
when you made a change in any of the row 9 source cells in Sheet1.

Gord

Gord,
thank you for the extention to a dynamic version. It works - but in
the wrong direction ;-(
I assume I mixed something up so you did not get the point.
To clarify my intention:

Sheet "Configuration" helds in A8:AF8 the comment text - since this
row may expands I defined a dynamic range "dynComments" for this
In sheet "ActionItemList" the cells in row a9:AF9 shall get the
comment of each cell in dynComments.

Your code assigns to all cells in "Configuration" (dynComments) the
comments of cells in range dynComments by change of sheet
"ActionItemList" - in your posting Sheet2.

How should I change your code?
Thanks Michael
 
M

Michael.Tarnowski

A little late getting back to you.

Try this revision which updates the Comments' contents.

Sub Comment_Add()
Dim addtext As String
Dim cmt As Comment
Dim rng As Range
Set rng = Sheets("Sheet2").Range("A8:M8")
For Each cell In rng
Set cmt = cell.Comment
addtext = cell.Offset(1, 0).Text
If cmt Is Nothing Then
Set cmt = cell.AddComment
cmt.Text Text:=addtext
Else
cmt.Text Text:=addtext
End If
Next cell
End Sub

To be truly dynamic, you could call it from some type of worksheet event
like calculate.

Private Sub Worksheet_Calculate()
Comment_Add
End Sub

The event code would be inserted into the Sheet2 module and would trigger
when you made a change in any of the row 9 source cells in Sheet1.

Gord

Gord,
thank you for the extention to a dynamic version. It works - but in
the wrong direction ;-(
I assume I mixed something up so you did not get the point.
To clarify my intention:

Sheet "Configuration" helds in A8:AF8 the comment text - since this
row may expands I defined a dynamic range "dynComments" for this
In sheet "ActionItemList" the cells in row a9:AF9 shall get the
comment of each cell in dynComments.

Your code assigns to all cells in "Configuration" (dynComments) the
comments of cells in range dynComments by change of sheet
"ActionItemList" - in your posting Sheet2.

How should I change your code?
Thanks Michael
 
G

Gord Dibben

I am confused.......easily done<g>

"Configuration" sheet contains text in cells in a range
"dynComments" of row 8

You want the text from each cell in this range to go into Comments in cells
of row 9 of "ActionItemsList" sheet

Am I close yet?


Gord
 
G

Gord Dibben

If you want, send me your workbook by email and I'll have a look at it.

I would prefer that to stumbling along here.

Change the AT and DOT as required.


Gord
 
M

Michael.Tarnowski

If you want, send me your workbook by email and I'll have a look at it.

I would prefer that to stumbling along here.

Change the AT and DOT as required.

Gord

Gord,
sorry about your confusion - my fault!

"Configuration" sheet contains text in cells in a range
"dynComments" of row 8
for the cells A9:AF9 of sheet "ActionItemList"
Thank you very much for your courtesy, I appreciate this very much
Hmm? - What do you mean? - I have the plain HTML gui only.

Michael
 
M

Michael.Tarnowski

If you want, send me your workbook by email and I'll have a look at it.

I would prefer that to stumbling along here.

Change the AT and DOT as required.

Gord

Gord,
sorry about your confusion - my fault!

"Configuration" sheet contains text in cells in a range
"dynComments" of row 8
for the cells A9:AF9 of sheet "ActionItemList"
Thank you very much for your courtesy, I appreciate this very much
Hmm? - What do you mean? - I have the plain HTML gui only.

Michael
 
G

Gord Dibben

My posted email is gordibbATshawDOTca

Change the AT and DOT to appropriate punctuation.


Gord
 
M

Michael.Tarnowski

My posted email is gordibbATshawDOTca


Change the AT and DOT to appropriate punctuation.

Gord

Hi Gord

I always receive the Mailer-demon error (the spaces in your address
were inserted by me):

"Hi. This is the qmail-send program at mail.gmx.net.
I'm afraid I wasn't able to deliver your message to the following
addresses.
This is a permanent error; I've given up. Sorry it didn't work out.

<gordibb @ shaw . ca>:
64.59.134.8_does_not_like_recipient./
Remote_host_said:_550_#5.1.0_Address_rejected_gordibb @ shaw . ca/
Giving_up_on_64.59.134.8./"
 
G

Gord Dibben

There are no spaces and please don't post the actual address.

I don't need the spam-bots picking it up.


Gord
 
M

Michael.Tarnowski

There are no spaces and please don't post the actual address.

I don't need the spam-bots picking it up.

Gord

I inserted the spaces to protect your email-address from robots;
please send me a mail with your address to emte69ATgmxDOTde
Sorry for any inconvience
Have a nice day
Michael
 
M

Michael.Tarnowski

There are no spaces and please don't post the actual address.

I don't need the spam-bots picking it up.

Gord

I inserted the spaces to protect your email-address from robots;
please send me a mail with your address to emte69ATgmxDOTde
Sorry for any inconvience
Have a nice day
Michael
 
M

Michael.Tarnowski

My mistake............left out one of the d's

I have sent you an email.

Gord

This community is really great! - It's an union of gorgeous and
generous people (like Gord) in helping others with the pitfalls of
Excel and VBA.
Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top