PC Review


Reply
Thread Tools Rate Thread

How to add this function to Personal Workbook

 
 
Gary
Guest
Posts: n/a
 
      29th Sep 2008
I have this *.bas file with the following code -

Attribute VB_Name = "Module1"

Function ConCatRange(CellBlock As Range) As String
Dim cell As Range
Dim sbuf As String
For Each cell In CellBlock
If Len(cell.Text) > 0 Then sbuf = sbuf & cell.Text & ", "
Next
ConCatRange = Left(sbuf, Len(sbuf) - 1)
End Function


How would I add this as a module or add-in so it would be available for use.
Right now, if I import the file it works but would rather not have to do
that for each new file.

Thanks.



 
Reply With Quote
 
 
 
 
Barb Reinhardt
Guest
Posts: n/a
 
      29th Sep 2008
I meant to say if you use

Set R1 = Range("B7:C12")

You get ...

Barb Reinhardt





"Gary" wrote:

> I have this *.bas file with the following code -
>
> Attribute VB_Name = "Module1"
>
> Function ConCatRange(CellBlock As Range) As String
> Dim cell As Range
> Dim sbuf As String
> For Each cell In CellBlock
> If Len(cell.Text) > 0 Then sbuf = sbuf & cell.Text & ", "
> Next
> ConCatRange = Left(sbuf, Len(sbuf) - 1)
> End Function
>
>
> How would I add this as a module or add-in so it would be available for use.
> Right now, if I import the file it works but would rather not have to do
> that for each new file.
>
> Thanks.
>
>
>

 
Reply With Quote
 
Gary
Guest
Posts: n/a
 
      29th Sep 2008
Barb,

I don't see your first response. Could you repost.

Thanks.

"Barb Reinhardt" wrote:

> I meant to say if you use
>
> Set R1 = Range("B7:C12")
>
> You get ...
>
> Barb Reinhardt
>
>
>
>
>
> "Gary" wrote:
>
> > I have this *.bas file with the following code -
> >
> > Attribute VB_Name = "Module1"
> >
> > Function ConCatRange(CellBlock As Range) As String
> > Dim cell As Range
> > Dim sbuf As String
> > For Each cell In CellBlock
> > If Len(cell.Text) > 0 Then sbuf = sbuf & cell.Text & ", "
> > Next
> > ConCatRange = Left(sbuf, Len(sbuf) - 1)
> > End Function
> >
> >
> > How would I add this as a module or add-in so it would be available for use.
> > Right now, if I import the file it works but would rather not have to do
> > that for each new file.
> >
> > Thanks.
> >
> >
> >

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      29th Sep 2008
So why not just add it to your personal.xls (or .xlsm or .xla) workbook?

You can copy and paste everything (ignore the "attribute" line) into a new
module in your personal workbook.

If your personal workbook is .xls, then use:
=personal.xls!concatrange(a1:a10)

if your personal workbook is .xla, then you can use:
=concatrange(a1:a10)


If you're new to macros:

Debra Dalgleish has some notes how to implement macros here:
http://www.contextures.com/xlvba01.html

David McRitchie has an intro to macros:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Ron de Bruin's intro to macros:
http://www.rondebruin.nl/code.htm

(General, Regular and Standard modules all describe the same thing.)


Gary wrote:
>
> I have this *.bas file with the following code -
>
> Attribute VB_Name = "Module1"
>
> Function ConCatRange(CellBlock As Range) As String
> Dim cell As Range
> Dim sbuf As String
> For Each cell In CellBlock
> If Len(cell.Text) > 0 Then sbuf = sbuf & cell.Text & ", "
> Next
> ConCatRange = Left(sbuf, Len(sbuf) - 1)
> End Function
>
> How would I add this as a module or add-in so it would be available for use.
> Right now, if I import the file it works but would rather not have to do
> that for each new file.
>
> Thanks.


--

Dave Peterson
 
Reply With Quote
 
Gary
Guest
Posts: n/a
 
      29th Sep 2008
Dave,

Thanks. I was trying that but didn't realize I needed the to include the
personal.xls file name in the call.

Working fine.


"Dave Peterson" wrote:

> So why not just add it to your personal.xls (or .xlsm or .xla) workbook?
>
> You can copy and paste everything (ignore the "attribute" line) into a new
> module in your personal workbook.
>
> If your personal workbook is .xls, then use:
> =personal.xls!concatrange(a1:a10)
>
> if your personal workbook is .xla, then you can use:
> =concatrange(a1:a10)
>
>
> If you're new to macros:
>
> Debra Dalgleish has some notes how to implement macros here:
> http://www.contextures.com/xlvba01.html
>
> David McRitchie has an intro to macros:
> http://www.mvps.org/dmcritchie/excel/getstarted.htm
>
> Ron de Bruin's intro to macros:
> http://www.rondebruin.nl/code.htm
>
> (General, Regular and Standard modules all describe the same thing.)
>
>
> Gary wrote:
> >
> > I have this *.bas file with the following code -
> >
> > Attribute VB_Name = "Module1"
> >
> > Function ConCatRange(CellBlock As Range) As String
> > Dim cell As Range
> > Dim sbuf As String
> > For Each cell In CellBlock
> > If Len(cell.Text) > 0 Then sbuf = sbuf & cell.Text & ", "
> > Next
> > ConCatRange = Left(sbuf, Len(sbuf) - 1)
> > End Function
> >
> > How would I add this as a module or add-in so it would be available for use.
> > Right now, if I import the file it works but would rather not have to do
> > that for each new file.
> >
> > Thanks.

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
Barb Reinhardt
Guest
Posts: n/a
 
      29th Sep 2008
Oops, wrong thread.

Barb Reinhardt




"Gary" wrote:

> Barb,
>
> I don't see your first response. Could you repost.
>
> Thanks.
>
> "Barb Reinhardt" wrote:
>
> > I meant to say if you use
> >
> > Set R1 = Range("B7:C12")
> >
> > You get ...
> >
> > Barb Reinhardt
> >
> >
> >
> >
> >
> > "Gary" wrote:
> >
> > > I have this *.bas file with the following code -
> > >
> > > Attribute VB_Name = "Module1"
> > >
> > > Function ConCatRange(CellBlock As Range) As String
> > > Dim cell As Range
> > > Dim sbuf As String
> > > For Each cell In CellBlock
> > > If Len(cell.Text) > 0 Then sbuf = sbuf & cell.Text & ", "
> > > Next
> > > ConCatRange = Left(sbuf, Len(sbuf) - 1)
> > > End Function
> > >
> > >
> > > How would I add this as a module or add-in so it would be available for use.
> > > Right now, if I import the file it works but would rather not have to do
> > > that for each new file.
> > >
> > > Thanks.
> > >
> > >
> > >

 
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
Re: Update Personal Workbook Macros when Workbook is opened. RyanH Microsoft Excel Programming 4 22nd Aug 2008 04:57 PM
Using a user-defined function from the Personal workbook mworth01 Microsoft Excel Programming 6 4th May 2006 02:12 PM
Personal macro workbook and personal.xls =?Utf-8?B?Sm9obiBLaWxrZW5ueQ==?= Microsoft Excel Misc 1 14th Jun 2005 09:43 PM
Calling a Personal.XLS Sub from anther workbook's 'This Workbook' Sheet Activate Jack Gillis Microsoft Excel Discussion 2 21st Mar 2005 11:58 PM
How to handle other workbook events through personal.xls workbook ivarsb Microsoft Excel Programming 1 27th Jul 2004 01:35 PM


Features
 

Advertising
 

Newsgroups
 


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