Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
arich
 
Posts: n/a
Default How dynamically create routing slip based on names in specific cel

The following macro creates a routing slip for two specific individuals. How
can I change this to create a routing slip based on the names entered in
specific spreadsheet cells?

Sub Macro5()
'
' Macro5 Macro
' Macro recorded 8/8/2005 by Xavier Cougart
'

Sheets("PAF Form").Copy
ActiveWorkbook.HasRoutingSlip = True
With ActiveWorkbook.RoutingSlip
. Recipients = Array("Roger Clemens", "Joe Torry")
. Subject = "Routing: Book1"
. Message = ""
. Delivery = x1OneAfterAnother
. ReturnWhenDone = True
. TrackStatus = True
End With
ActiveWorkbook.Route



  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

Are the cells nice and contiguous?

If yes, you may be able to use something like:

Option Explicit
Sub testme()

Dim myNames As Variant

With Worksheets("sheet1")
myNames = .Range("A1", .Cells(.Rows.Count, "A").End(xlUp)).Value
End With

Sheets("PAF Form").Copy
ActiveWorkbook.HasRoutingSlip = False
ActiveWorkbook.HasRoutingSlip = True
With ActiveWorkbook.RoutingSlip
.Recipients = myNames
.Subject = "Routing: Book1"
.Message = ""
.Delivery = xlOneAfterAnother
.ReturnWhenDone = True
.TrackStatus = True
End With
ActiveWorkbook.Route

End Sub

I just picked up the names/addresses from sheet1--starting in A1 to the last
used cell in column A.

If the cells are discontiguous, you could build an array:

Option Explicit
Sub testme2()

Dim myRng As Range
Dim myCell As Range
Dim myNames() As String
Dim iCtr As Long

With Worksheets("sheet1")
Set myRng = .Range("a1:b9,d14,e52")
End With

ReDim myNames(1 To myRng.Cells.Count)

iCtr = 0
For Each myCell In myRng.Cells
iCtr = iCtr + 1
myNames(iCtr) = myCell.Value
Next myCell

ActiveWorkbook.HasRoutingSlip = False
ActiveWorkbook.HasRoutingSlip = True
With ActiveWorkbook.RoutingSlip
.Recipients = myNames
.Subject = "Routing: Book1"
.Message = ""
.Delivery = xlOneAfterAnother
.ReturnWhenDone = True
.TrackStatus = True
End With
ActiveWorkbook.Route

End Sub

And be careful.

This line:
..Delivery = xlOneAfterAnother
had a typo.
It's xl (ex-ell), not ex-one.

arich wrote:

The following macro creates a routing slip for two specific individuals. How
can I change this to create a routing slip based on the names entered in
specific spreadsheet cells?

Sub Macro5()
'
' Macro5 Macro
' Macro recorded 8/8/2005 by Xavier Cougart
'

Sheets("PAF Form").Copy
ActiveWorkbook.HasRoutingSlip = True
With ActiveWorkbook.RoutingSlip
. Recipients = Array("Roger Clemens", "Joe Torry")
. Subject = "Routing: Book1"
. Message = ""
. Delivery = x1OneAfterAnother
. ReturnWhenDone = True
. TrackStatus = True
End With
ActiveWorkbook.Route


--

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
Create a report with selected rows based on the content in a cell ThirdTim New Users to Excel 1 May 5th 05 05:18 PM
Create Total based on lookup value Kim Excel Worksheet Functions 5 May 2nd 05 08:55 PM
how to create and use a new spreadsheet based on a template Shady Excel Discussion (Misc queries) 3 April 3rd 05 09:50 PM
How to create a calculated field formula based on Pivot Table resu dha17 Excel Discussion (Misc queries) 1 December 15th 04 05:39 AM
Create a total based on multiple conditions is not giving correct. Jacob Excel Worksheet Functions 2 November 4th 04 04:07 AM


All times are GMT +1. The time now is 07:55 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"