Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default Export comment fields

I have a user who has been using the comments field to store his client
addresses. He now wants the spreadsheet exported from excel into outlook. Is
there any way to export the comments? Or move them into cells on the
spreadsheet.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Export comment fields

Saved from a previous post:

You can retrieve the text from a comment with a userdefined function like:

Option Explicit
Function GetComment(FCell As Range) As Variant
Application.Volatile

Set FCell = FCell.Cells(1)

If FCell.Comment Is Nothing Then
GetComment = ""
Else
GetComment = FCell.Comment.Text
End If

End Function

Then you can use it like any other function:

=getcomment(a1)

But be aware that the function won't evaluate when you just change the comment.
It'll be correct when excel recalculates. (Hit F9 to force a recalc.)

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm


BWAnnie wrote:

I have a user who has been using the comments field to store his client
addresses. He now wants the spreadsheet exported from excel into outlook. Is
there any way to export the comments? Or move them into cells on the
spreadsheet.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 527
Default Export comment fields

Nice one Dave. But I think Annie wants a list that she can copy.

Annie

If a user has entered addresses in comments it is hard to imagine how she
may have entered it - and this would be depend on the solution. The first
macro will show a message with the text in each comment in turn.

Sub ShowCmtText()
Dim cmt
Dim sMsg As String

For Each cmt In ActiveSheet.Comments
sMsg = cmt.Text
MsgBox sMsg
Next cmt
End Sub

If the Names and addresses are shown in separate lines then the following
sub will copy the details to sheet2 (Change this to suit). If the address
details are separated by a comma you will have to change the code as detailed
in the sub below

Sub CommentTextToSheet2()
' sheet with comments variables
Dim cmt
Dim sMsg As String
Dim colCount As Integer
Dim iLen As Integer
Dim iIndex As Integer
Dim client As Variant
' Destination sheet variables
Dim wksDest As Worksheet
Dim lNextrow As Long
Dim rngTemp As Range
Set wksDest = Sheets("Sheet2")

For Each cmt In ActiveSheet.Comments
colCount = 1
sMsg = cmt.Text
iLen = Len(sMsg)
For iIndex = 1 To iLen
If Mid(sMsg, iIndex, 1) = vbLf Then
colCount = colCount + 1
End If
Next iIndex

client = Split(sMsg, vbLf)

'or if comma separated use - put an apostophe before the line above
' and remove the apostrophe on the next line

' client = split(smasg,","

With Sheets("Sheet2")
lNextrow = .Range("A1").CurrentRegion.Rows.Count + 1
Set rngTemp = .Range("A" & lNextrow & ":" & Cells(lNextrow,
colCount).Address)
rngTemp = client
End With

Next cmt

End Sub


If the details are separated by spaces, this will not do - 21 The Hi Road
would shown in four columns. If this is the case, Each comment will have to
be edited & a hard return made between each field. Address1, Address2 and so
on.

Once you have the list on a separate sheet you can think about importing the
data int Outlook - I have not done this I'm afraid.

Regards
Peter Atherton

"Dave Peterson" wrote:

Saved from a previous post:

You can retrieve the text from a comment with a userdefined function like:

Option Explicit
Function GetComment(FCell As Range) As Variant
Application.Volatile

Set FCell = FCell.Cells(1)

If FCell.Comment Is Nothing Then
GetComment = ""
Else
GetComment = FCell.Comment.Text
End If

End Function

Then you can use it like any other function:

=getcomment(a1)

But be aware that the function won't evaluate when you just change the comment.
It'll be correct when excel recalculates. (Hit F9 to force a recalc.)

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm


BWAnnie wrote:

I have a user who has been using the comments field to store his client
addresses. He now wants the spreadsheet exported from excel into outlook. Is
there any way to export the comments? Or move them into cells on the
spreadsheet.


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Export comment fields

I would have expected that the comments were in the same field/column in the
excel data. Then the OP could use the UDF to retrieve the comment into a cell
on that same row.

Then it could be easier to import those comments (along with the other fields)
into Outlook.

Billy Liddel wrote:

Nice one Dave. But I think Annie wants a list that she can copy.

Annie

If a user has entered addresses in comments it is hard to imagine how she
may have entered it - and this would be depend on the solution. The first
macro will show a message with the text in each comment in turn.

Sub ShowCmtText()
Dim cmt
Dim sMsg As String

For Each cmt In ActiveSheet.Comments
sMsg = cmt.Text
MsgBox sMsg
Next cmt
End Sub

If the Names and addresses are shown in separate lines then the following
sub will copy the details to sheet2 (Change this to suit). If the address
details are separated by a comma you will have to change the code as detailed
in the sub below

Sub CommentTextToSheet2()
' sheet with comments variables
Dim cmt
Dim sMsg As String
Dim colCount As Integer
Dim iLen As Integer
Dim iIndex As Integer
Dim client As Variant
' Destination sheet variables
Dim wksDest As Worksheet
Dim lNextrow As Long
Dim rngTemp As Range
Set wksDest = Sheets("Sheet2")

For Each cmt In ActiveSheet.Comments
colCount = 1
sMsg = cmt.Text
iLen = Len(sMsg)
For iIndex = 1 To iLen
If Mid(sMsg, iIndex, 1) = vbLf Then
colCount = colCount + 1
End If
Next iIndex

client = Split(sMsg, vbLf)

'or if comma separated use - put an apostophe before the line above
' and remove the apostrophe on the next line

' client = split(smasg,","

With Sheets("Sheet2")
lNextrow = .Range("A1").CurrentRegion.Rows.Count + 1
Set rngTemp = .Range("A" & lNextrow & ":" & Cells(lNextrow,
colCount).Address)
rngTemp = client
End With

Next cmt

End Sub

If the details are separated by spaces, this will not do - 21 The Hi Road
would shown in four columns. If this is the case, Each comment will have to
be edited & a hard return made between each field. Address1, Address2 and so
on.

Once you have the list on a separate sheet you can think about importing the
data int Outlook - I have not done this I'm afraid.

Regards
Peter Atherton

"Dave Peterson" wrote:

Saved from a previous post:

You can retrieve the text from a comment with a userdefined function like:

Option Explicit
Function GetComment(FCell As Range) As Variant
Application.Volatile

Set FCell = FCell.Cells(1)

If FCell.Comment Is Nothing Then
GetComment = ""
Else
GetComment = FCell.Comment.Text
End If

End Function

Then you can use it like any other function:

=getcomment(a1)

But be aware that the function won't evaluate when you just change the comment.
It'll be correct when excel recalculates. (Hit F9 to force a recalc.)

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm


BWAnnie wrote:

I have a user who has been using the comments field to store his client
addresses. He now wants the spreadsheet exported from excel into outlook. Is
there any way to export the comments? Or move them into cells on the
spreadsheet.


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 527
Default Export comment fields

Good point, but what goes into the actual cell? I thought the use of comments
was to save space so that the cells could be used for something else, maybe
an ID or invoice number.

Anyway the OP has a choice - I guess we are working in the dark most of the
time.

Gegards
Peter

"Dave Peterson" wrote:

I would have expected that the comments were in the same field/column in the
excel data. Then the OP could use the UDF to retrieve the comment into a cell
on that same row.

Then it could be easier to import those comments (along with the other fields)
into Outlook.

Billy Liddel wrote:

Nice one Dave. But I think Annie wants a list that she can copy.

Annie

If a user has entered addresses in comments it is hard to imagine how she
may have entered it - and this would be depend on the solution. The first
macro will show a message with the text in each comment in turn.

Sub ShowCmtText()
Dim cmt
Dim sMsg As String

For Each cmt In ActiveSheet.Comments
sMsg = cmt.Text
MsgBox sMsg
Next cmt
End Sub

If the Names and addresses are shown in separate lines then the following
sub will copy the details to sheet2 (Change this to suit). If the address
details are separated by a comma you will have to change the code as detailed
in the sub below

Sub CommentTextToSheet2()
' sheet with comments variables
Dim cmt
Dim sMsg As String
Dim colCount As Integer
Dim iLen As Integer
Dim iIndex As Integer
Dim client As Variant
' Destination sheet variables
Dim wksDest As Worksheet
Dim lNextrow As Long
Dim rngTemp As Range
Set wksDest = Sheets("Sheet2")

For Each cmt In ActiveSheet.Comments
colCount = 1
sMsg = cmt.Text
iLen = Len(sMsg)
For iIndex = 1 To iLen
If Mid(sMsg, iIndex, 1) = vbLf Then
colCount = colCount + 1
End If
Next iIndex

client = Split(sMsg, vbLf)

'or if comma separated use - put an apostophe before the line above
' and remove the apostrophe on the next line

' client = split(smasg,","

With Sheets("Sheet2")
lNextrow = .Range("A1").CurrentRegion.Rows.Count + 1
Set rngTemp = .Range("A" & lNextrow & ":" & Cells(lNextrow,
colCount).Address)
rngTemp = client
End With

Next cmt

End Sub

If the details are separated by spaces, this will not do - 21 The Hi Road
would shown in four columns. If this is the case, Each comment will have to
be edited & a hard return made between each field. Address1, Address2 and so
on.

Once you have the list on a separate sheet you can think about importing the
data int Outlook - I have not done this I'm afraid.

Regards
Peter Atherton

"Dave Peterson" wrote:

Saved from a previous post:

You can retrieve the text from a comment with a userdefined function like:

Option Explicit
Function GetComment(FCell As Range) As Variant
Application.Volatile

Set FCell = FCell.Cells(1)

If FCell.Comment Is Nothing Then
GetComment = ""
Else
GetComment = FCell.Comment.Text
End If

End Function

Then you can use it like any other function:

=getcomment(a1)

But be aware that the function won't evaluate when you just change the comment.
It'll be correct when excel recalculates. (Hit F9 to force a recalc.)

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm


BWAnnie wrote:

I have a user who has been using the comments field to store his client
addresses. He now wants the spreadsheet exported from excel into outlook. Is
there any way to export the comments? Or move them into cells on the
spreadsheet.

--

Dave Peterson


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Export comment fields

I try to use comments sparingly.

Even with 256 columns, I can't remember running out of fields--and with 16k
columns in xl2007, it's even more unlikely.

Billy Liddel wrote:

Good point, but what goes into the actual cell? I thought the use of comments
was to save space so that the cells could be used for something else, maybe
an ID or invoice number.

Anyway the OP has a choice - I guess we are working in the dark most of the
time.

Gegards
Peter

"Dave Peterson" wrote:

I would have expected that the comments were in the same field/column in the
excel data. Then the OP could use the UDF to retrieve the comment into a cell
on that same row.

Then it could be easier to import those comments (along with the other fields)
into Outlook.

Billy Liddel wrote:

Nice one Dave. But I think Annie wants a list that she can copy.

Annie

If a user has entered addresses in comments it is hard to imagine how she
may have entered it - and this would be depend on the solution. The first
macro will show a message with the text in each comment in turn.

Sub ShowCmtText()
Dim cmt
Dim sMsg As String

For Each cmt In ActiveSheet.Comments
sMsg = cmt.Text
MsgBox sMsg
Next cmt
End Sub

If the Names and addresses are shown in separate lines then the following
sub will copy the details to sheet2 (Change this to suit). If the address
details are separated by a comma you will have to change the code as detailed
in the sub below

Sub CommentTextToSheet2()
' sheet with comments variables
Dim cmt
Dim sMsg As String
Dim colCount As Integer
Dim iLen As Integer
Dim iIndex As Integer
Dim client As Variant
' Destination sheet variables
Dim wksDest As Worksheet
Dim lNextrow As Long
Dim rngTemp As Range
Set wksDest = Sheets("Sheet2")

For Each cmt In ActiveSheet.Comments
colCount = 1
sMsg = cmt.Text
iLen = Len(sMsg)
For iIndex = 1 To iLen
If Mid(sMsg, iIndex, 1) = vbLf Then
colCount = colCount + 1
End If
Next iIndex

client = Split(sMsg, vbLf)

'or if comma separated use - put an apostophe before the line above
' and remove the apostrophe on the next line

' client = split(smasg,","

With Sheets("Sheet2")
lNextrow = .Range("A1").CurrentRegion.Rows.Count + 1
Set rngTemp = .Range("A" & lNextrow & ":" & Cells(lNextrow,
colCount).Address)
rngTemp = client
End With

Next cmt

End Sub

If the details are separated by spaces, this will not do - 21 The Hi Road
would shown in four columns. If this is the case, Each comment will have to
be edited & a hard return made between each field. Address1, Address2 and so
on.

Once you have the list on a separate sheet you can think about importing the
data int Outlook - I have not done this I'm afraid.

Regards
Peter Atherton

"Dave Peterson" wrote:

Saved from a previous post:

You can retrieve the text from a comment with a userdefined function like:

Option Explicit
Function GetComment(FCell As Range) As Variant
Application.Volatile

Set FCell = FCell.Cells(1)

If FCell.Comment Is Nothing Then
GetComment = ""
Else
GetComment = FCell.Comment.Text
End If

End Function

Then you can use it like any other function:

=getcomment(a1)

But be aware that the function won't evaluate when you just change the comment.
It'll be correct when excel recalculates. (Hit F9 to force a recalc.)

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm


BWAnnie wrote:

I have a user who has been using the comments field to store his client
addresses. He now wants the spreadsheet exported from excel into outlook. Is
there any way to export the comments? Or move them into cells on the
spreadsheet.

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
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
Have 2 create 2 new date fields after export from MS project 4 piv Bendinblues Excel Discussion (Misc queries) 0 January 2nd 08 12:05 PM
export re-order input fields to export file [csv] madisonpete Excel Worksheet Functions 0 November 30th 07 03:51 PM
Access -> Excel: How to export fields > 255 characters Gabriel Martin Excel Discussion (Misc queries) 1 March 9th 05 01:37 PM
How do I export a csv file from Excel with fields enclosed in dou. mk_webman Excel Discussion (Misc queries) 2 December 24th 04 02:39 PM
Formatting date fields after export Raymond Excel Discussion (Misc queries) 2 December 1st 04 12:04 AM


All times are GMT +1. The time now is 11:35 PM.

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"