PC Review


Reply
Thread Tools Rate Thread

Comment Box To Multipul Cells

 
 
N1KO
Guest
Posts: n/a
 
      12th Jun 2009
I've got a macro that takes text from cells and puts them into a comment box.

People have now decided that they want the text on a new sheet as well as in
a comment box.

To save me having to reload 180 reports is there any way to take the text
from the comment box and put into cells. I need a new cell (on a new line)
for each line in the comment box.

Each comment box holds a maximum of 5 comments, each comment starts on a new
line in the box. There can be less though.

I can put the code to get it into the comment box if it'll help.

Thanks to everyone that's helped me for the past few requests, managers are
starting to ask for some stupid things now.

N1KO
 
Reply With Quote
 
 
 
 
r
Guest
Posts: n/a
 
      12th Jun 2009
to adapt ...

Sub test()
Dim rng As Excel.Range
Dim rngr As Excel.Range
Dim rngT As Excel.Range
Dim s As String, v, t, r As Long, c As Long

On Error Resume Next
Set rng = ActiveSheet.UsedRange.SpecialCells(xlCellTypeComments)
If Err Then
Exit Sub
End If
On Error GoTo 0

Set rngr = Nuovo_Range(ThisWorkbook)

For Each rngT In rng
c = 0
s = rngT.Comment.Text
v = Split(s, vbLf)

rngr.Offset(r, c) = rngT.Address(, , , True)
c = c + 1

For Each t In v
rngr.Offset(r, c) = t
c = c + 1
Next

r = r + 1
Next

End Sub
Function Nuovo_Range( _
Wb As Excel.Workbook, _
Optional Nome_base As _
String = "Res") As Excel.Range

Dim b
Set Nuovo_Range = Wb.Worksheets.Add.Range("A1")

Application.ScreenUpdating = False
On Error Resume Next
Do
Err.Clear
b = b + 1
Nuovo_Range.Parent.Name = Nome_base & b
Loop While Err
Application.ScreenUpdating = True

End Function

regards
r

Il mio ultimo lavoro ...
http://excelvba.altervista.org/blog/...ternative.html


"N1KO" wrote:

> I've got a macro that takes text from cells and puts them into a comment box.
>
> People have now decided that they want the text on a new sheet as well as in
> a comment box.
>
> To save me having to reload 180 reports is there any way to take the text
> from the comment box and put into cells. I need a new cell (on a new line)
> for each line in the comment box.
>
> Each comment box holds a maximum of 5 comments, each comment starts on a new
> line in the box. There can be less though.
>
> I can put the code to get it into the comment box if it'll help.
>
> Thanks to everyone that's helped me for the past few requests, managers are
> starting to ask for some stupid things now.
>
> N1KO

 
Reply With Quote
 
N1KO
Guest
Posts: n/a
 
      14th Jun 2009
You've saved me a lot of work, I've adapted it slightly to change the columns
to rows but other than that its working brilliantly.

Thanks

"r" wrote:

> to adapt ...
>
> Sub test()
> Dim rng As Excel.Range
> Dim rngr As Excel.Range
> Dim rngT As Excel.Range
> Dim s As String, v, t, r As Long, c As Long
>
> On Error Resume Next
> Set rng = ActiveSheet.UsedRange.SpecialCells(xlCellTypeComments)
> If Err Then
> Exit Sub
> End If
> On Error GoTo 0
>
> Set rngr = Nuovo_Range(ThisWorkbook)
>
> For Each rngT In rng
> c = 0
> s = rngT.Comment.Text
> v = Split(s, vbLf)
>
> rngr.Offset(r, c) = rngT.Address(, , , True)
> c = c + 1
>
> For Each t In v
> rngr.Offset(r, c) = t
> c = c + 1
> Next
>
> r = r + 1
> Next
>
> End Sub
> Function Nuovo_Range( _
> Wb As Excel.Workbook, _
> Optional Nome_base As _
> String = "Res") As Excel.Range
>
> Dim b
> Set Nuovo_Range = Wb.Worksheets.Add.Range("A1")
>
> Application.ScreenUpdating = False
> On Error Resume Next
> Do
> Err.Clear
> b = b + 1
> Nuovo_Range.Parent.Name = Nome_base & b
> Loop While Err
> Application.ScreenUpdating = True
>
> End Function
>
> regards
> r
>
> Il mio ultimo lavoro ...
> http://excelvba.altervista.org/blog/...ternative.html
>
>
> "N1KO" wrote:
>
> > I've got a macro that takes text from cells and puts them into a comment box.
> >
> > People have now decided that they want the text on a new sheet as well as in
> > a comment box.
> >
> > To save me having to reload 180 reports is there any way to take the text
> > from the comment box and put into cells. I need a new cell (on a new line)
> > for each line in the comment box.
> >
> > Each comment box holds a maximum of 5 comments, each comment starts on a new
> > line in the box. There can be less though.
> >
> > I can put the code to get it into the comment box if it'll help.
> >
> > Thanks to everyone that's helped me for the past few requests, managers are
> > starting to ask for some stupid things now.
> >
> > N1KO

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
text in multipul cells Brendon Microsoft Excel Misc 3 17th Nov 2008 10:32 PM
link a comment to two cells bikermajor Microsoft Excel Misc 0 15th Jan 2008 02:04 PM
How to copy comment box to other cells =?Utf-8?B?Q1lOVEhJQQ==?= Microsoft Excel Misc 3 7th Nov 2007 10:37 PM
Adding comment to cells not working with merged cells =?Utf-8?B?bWNwaGM=?= Microsoft Excel Programming 2 29th Aug 2007 07:09 PM
Cells.Comment =?Utf-8?B?QmhhcmF0aCBSYWphbWFuaQ==?= Microsoft Excel Programming 1 4th Aug 2006 10:29 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:08 PM.