[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.javascript

Trying to get a random image js to scroll left & right

super70s

7/17/2014 4:55:00 AM

Hi, I'm trying to get this JS of 150 images which load randomly to
scroll left & right using arrows, similar to what Amazon.com does with
their "Customers also bought..." movie suggestions. Anybody know how to
fix this to get it to do that? Thank you.


<head>

<script type="text/javascript" src="randomAds.js"></script>

</head>

<p align="center">
<script type="text/javascript">
randomorder(adblock, ' ')
</script>
</p>



Here's the accompanying randomAds.js text file:

var adblock=new Array()
adblock[0]='<a href="spcooperalice6.html"><img class="hover"
src="http://www.myurl.com/mugshots/A/Alice_Cooper/images/Alice_...
if" class="imgBorder"></a>'
adblock[1]='<a href="spacdc.html"><img class="hover"
src="http://www.myurl.com/mugshots/A/Angus_Young/images/Angus_Young4...
class="imgBorder"></a>'

....etc., etc., etc., 146 more images....

images/Warren_Zevon9.gif" class="imgBorder"></a>'
adblock[149]='<a href="foghat.html"><img class="hover"
src="http://www.myurl.com/mugshots/D/images/Dave_Peverett3...
class="imgBorder"></a>'
adblock[150]='<a href="spmasondave.html"><img class="hover"
src="http://www.myurl/mugshots/D/Dave_Mason/images/Dave_Mason2...
class="imgBorder"></a>'

function randomorder(targetarray, spacing) {
var randomorder=new Array()
var the_one
var z=141
for (i=0;i<targetarray.length;i++)
randomorder[i]=i

while (z<targetarray.length) {
the_one=Math.floor(Math.random()*targetarray.length)
if (targetarray[the_one]!="_selected!"){
document.write(targetarray[the_one]+spacing)
targetarray[the_one]="_selected!"
z++
}
}
}
20 Answers

Ron de Bruin

7/28/2009 4:05:00 PM

0

Hi Sam

Try this

Sub Mail_Range()
'Working in 2000-2007
Dim Source As Range
Dim Dest As Workbook
Dim wb As Workbook
Dim TempFilePath As String
Dim TempFileName As String
Dim FileExtStr As String
Dim FileFormatNum As Long
Dim Lrow As Long

Lrow = LastRow(ActiveSheet)

Set Source = Nothing
On Error Resume Next
Set Source = Range("A" & Lrow & ":K" &
Lrow).SpecialCells(xlCellTypeVisible)
On Error GoTo 0

If Source Is Nothing Then
MsgBox "The source is not a range or the sheet is protected, " & _
"please correct and try again.", vbOKOnly
Exit Sub
End If

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

Set wb = ActiveWorkbook
Set Dest = Workbooks.Add(xlWBATWorksheet)

Source.Copy
With Dest.Sheets(1)
.Cells(1).PasteSpecial Paste:=8
.Cells(1).PasteSpecial Paste:=xlPasteValues
.Cells(1).PasteSpecial Paste:=xlPasteFormats
.Cells(1).Select
Application.CutCopyMode = False
End With

TempFilePath = Environ$("temp") & "\"
TempFileName = "Selection of " & wb.Name & " " _
& Format(Now, "dd-mmm-yy h-mm-ss")

If Val(Application.Version) < 12 Then
'You use Excel 2000-2003
FileExtStr = ".xls": FileFormatNum = -4143
Else
'You use Excel 2007
FileExtStr = ".xlsx": FileFormatNum = 51
End If

With Dest

.SaveAs TempFilePath & TempFileName & FileExtStr, _
FileFormat:=FileFormatNum
On Error Resume Next
.SendMail "rondebruin@kabelfoon.nl", _
"This is the Subject line"
On Error GoTo 0
.Close SaveChanges:=False
End With

Kill TempFilePath & TempFileName & FileExtStr

With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub

Function LastRow(sh As Worksheet)
On Error Resume Next
LastRow = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
On Error GoTo 0
End Function



"sam" <sam@discussions.microsoft.com> schreef in bericht
news:72EF3B4A-476D-4239-ACA9-1D273BD8B180@microsoft.com...
> Thanks for your reply Ron,
> I have 26 cells of data in a row that I need to mail, from A to Z, I have
> to
> send it as an excel attachment.
>
> Thanks in advance
>
> "Ron de Bruin" wrote:
>
>> Hi Sam
>>
>> How many cells with data have a row ?
>>
>> Do you want to send it in the body or in a workbook
>>
>>
>> "sam" <sam@discussions.microsoft.com> schreef in bericht
>> news:85987E9F-C95C-470C-A063-A9583C53B3B4@microsoft.com...
>> > Hi All,
>> >
>> > I have a userform that accepts user inputs and emails it to me once
>> > users
>> > click "Submit" on the userform. Before being emailed they are stored in
>> > a
>> > workbook on a shared drive.
>> >
>> > What is happening is: this workbook that is emailed to me stores the
>> > user
>> > inputs of each user in a separate row, and hence I am receiving the
>> > whole
>> > workbook with inputs of all the users.
>> >
>> > What I want: I want to receive just the current user???s data. I dont
>> > want
>> > to
>> > receive the entire workbook, but the data that has been inputted by the
>> > last
>> > user only. (For e.g. only the last row updated in the workbook) and not
>> > whole
>> > workbook.
>> >
>> > Is there some code I can put in that will email me just the last user
>> > input
>> > and not the previous inputs?
>> >
>> > Please help
>> > I hope I made it clear
>> >
>> > Thanks in Advance
>> >
>> > __________ Information from ESET Smart Security, version of virus
>> > signature database 4285 (20090728) __________
>> >
>> > The message was checked by ESET Smart Security.
>> >
>> > http://ww...
>> >
>> >
>> >
>>
>>
>> __________ Information from ESET Smart Security, version of virus
>> signature database 4285 (20090728) __________
>>
>> The message was checked by ESET Smart Security.
>>
>> http://ww...
>>
>>
>>
>>
>
> __________ Information from ESET Smart Security, version of virus
> signature database 4285 (20090728) __________
>
> The message was checked by ESET Smart Security.
>
> http://ww...
>
>
>


__________ Information from ESET Smart Security, version of virus signature database 4285 (20090728) __________

The message was checked by ESET Smart Security.

http://ww...



Ron de Bruin

7/28/2009 4:11:00 PM

0

Change the mail address to yours before you test it


"Ron de Bruin" <rondebruin@kabelfoon.nl> schreef in bericht
news:%23hQpB15DKHA.4064@TK2MSFTNGP04.phx.gbl...
> Hi Sam
>
> Try this
>
> Sub Mail_Range()
> 'Working in 2000-2007
> Dim Source As Range
> Dim Dest As Workbook
> Dim wb As Workbook
> Dim TempFilePath As String
> Dim TempFileName As String
> Dim FileExtStr As String
> Dim FileFormatNum As Long
> Dim Lrow As Long
>
> Lrow = LastRow(ActiveSheet)
>
> Set Source = Nothing
> On Error Resume Next
> Set Source = Range("A" & Lrow & ":K" &
> Lrow).SpecialCells(xlCellTypeVisible)
> On Error GoTo 0
>
> If Source Is Nothing Then
> MsgBox "The source is not a range or the sheet is protected, " & _
> "please correct and try again.", vbOKOnly
> Exit Sub
> End If
>
> With Application
> .ScreenUpdating = False
> .EnableEvents = False
> End With
>
> Set wb = ActiveWorkbook
> Set Dest = Workbooks.Add(xlWBATWorksheet)
>
> Source.Copy
> With Dest.Sheets(1)
> .Cells(1).PasteSpecial Paste:=8
> .Cells(1).PasteSpecial Paste:=xlPasteValues
> .Cells(1).PasteSpecial Paste:=xlPasteFormats
> .Cells(1).Select
> Application.CutCopyMode = False
> End With
>
> TempFilePath = Environ$("temp") & "\"
> TempFileName = "Selection of " & wb.Name & " " _
> & Format(Now, "dd-mmm-yy h-mm-ss")
>
> If Val(Application.Version) < 12 Then
> 'You use Excel 2000-2003
> FileExtStr = ".xls": FileFormatNum = -4143
> Else
> 'You use Excel 2007
> FileExtStr = ".xlsx": FileFormatNum = 51
> End If
>
> With Dest
>
> .SaveAs TempFilePath & TempFileName & FileExtStr, _
> FileFormat:=FileFormatNum
> On Error Resume Next
> .SendMail "rondebruin@kabelfoon.nl", _
> "This is the Subject line"
> On Error GoTo 0
> .Close SaveChanges:=False
> End With
>
> Kill TempFilePath & TempFileName & FileExtStr
>
> With Application
> .ScreenUpdating = True
> .EnableEvents = True
> End With
> End Sub
>
> Function LastRow(sh As Worksheet)
> On Error Resume Next
> LastRow = sh.Cells.Find(What:="*", _
> After:=sh.Range("A1"), _
> Lookat:=xlPart, _
> LookIn:=xlFormulas, _
> SearchOrder:=xlByRows, _
> SearchDirection:=xlPrevious, _
> MatchCase:=False).Row
> On Error GoTo 0
> End Function
>
>
>
> "sam" <sam@discussions.microsoft.com> schreef in bericht
> news:72EF3B4A-476D-4239-ACA9-1D273BD8B180@microsoft.com...
>> Thanks for your reply Ron,
>> I have 26 cells of data in a row that I need to mail, from A to Z, I have
>> to
>> send it as an excel attachment.
>>
>> Thanks in advance
>>
>> "Ron de Bruin" wrote:
>>
>>> Hi Sam
>>>
>>> How many cells with data have a row ?
>>>
>>> Do you want to send it in the body or in a workbook
>>>
>>>
>>> "sam" <sam@discussions.microsoft.com> schreef in bericht
>>> news:85987E9F-C95C-470C-A063-A9583C53B3B4@microsoft.com...
>>> > Hi All,
>>> >
>>> > I have a userform that accepts user inputs and emails it to me once
>>> > users
>>> > click "Submit" on the userform. Before being emailed they are stored
>>> > in a
>>> > workbook on a shared drive.
>>> >
>>> > What is happening is: this workbook that is emailed to me stores the
>>> > user
>>> > inputs of each user in a separate row, and hence I am receiving the
>>> > whole
>>> > workbook with inputs of all the users.
>>> >
>>> > What I want: I want to receive just the current user???s data. I dont
>>> > want
>>> > to
>>> > receive the entire workbook, but the data that has been inputted by
>>> > the
>>> > last
>>> > user only. (For e.g. only the last row updated in the workbook) and
>>> > not
>>> > whole
>>> > workbook.
>>> >
>>> > Is there some code I can put in that will email me just the last user
>>> > input
>>> > and not the previous inputs?
>>> >
>>> > Please help
>>> > I hope I made it clear
>>> >
>>> > Thanks in Advance
>>> >
>>> > __________ Information from ESET Smart Security, version of virus
>>> > signature database 4285 (20090728) __________
>>> >
>>> > The message was checked by ESET Smart Security.
>>> >
>>> > http://ww...
>>> >
>>> >
>>> >
>>>
>>>
>>> __________ Information from ESET Smart Security, version of virus
>>> signature database 4285 (20090728) __________
>>>
>>> The message was checked by ESET Smart Security.
>>>
>>> http://ww...
>>>
>>>
>>>
>>>
>>
>> __________ Information from ESET Smart Security, version of virus
>> signature database 4285 (20090728) __________
>>
>> The message was checked by ESET Smart Security.
>>
>> http://ww...
>>
>>
>>
>
>
> __________ Information from ESET Smart Security, version of virus
> signature database 4285 (20090728) __________
>
> The message was checked by ESET Smart Security.
>
> http://ww...
>
>
>


__________ Information from ESET Smart Security, version of virus signature database 4285 (20090728) __________

The message was checked by ESET Smart Security.

http://ww...



sam

7/28/2009 5:15:00 PM

0

Hey Ron, This worked out great. Thanks a Lot for your help.
One thing I also wanted was to mail column headers with the last updated
row.. The first row contains column headers and I would like to mail that as
well.
I tried updaing this part of the code:

Set Source = Range("A" & Lrow & ":K" & Lrow).SpecialCells(xlCellTypeVisible)

to:

Set Source = Range("A" & Lrow & ":K" & Lrow &
Frow).SpecialCells(xlCellTypeVisible)

But it didnt mail the first row, ALso when I it mails, it asks me to allow
or deny the macro to mail the book, should I set Application.DisplayAlerts =
False ?

Thanks a lot again.


"Ron de Bruin" wrote:

> Change the mail address to yours before you test it
>
>
> "Ron de Bruin" <rondebruin@kabelfoon.nl> schreef in bericht
> news:%23hQpB15DKHA.4064@TK2MSFTNGP04.phx.gbl...
> > Hi Sam
> >
> > Try this
> >
> > Sub Mail_Range()
> > 'Working in 2000-2007
> > Dim Source As Range
> > Dim Dest As Workbook
> > Dim wb As Workbook
> > Dim TempFilePath As String
> > Dim TempFileName As String
> > Dim FileExtStr As String
> > Dim FileFormatNum As Long
> > Dim Lrow As Long
> >
> > Lrow = LastRow(ActiveSheet)
> >
> > Set Source = Nothing
> > On Error Resume Next
> > Set Source = Range("A" & Lrow & ":K" &
> > Lrow).SpecialCells(xlCellTypeVisible)
> > On Error GoTo 0
> >
> > If Source Is Nothing Then
> > MsgBox "The source is not a range or the sheet is protected, " & _
> > "please correct and try again.", vbOKOnly
> > Exit Sub
> > End If
> >
> > With Application
> > .ScreenUpdating = False
> > .EnableEvents = False
> > End With
> >
> > Set wb = ActiveWorkbook
> > Set Dest = Workbooks.Add(xlWBATWorksheet)
> >
> > Source.Copy
> > With Dest.Sheets(1)
> > .Cells(1).PasteSpecial Paste:=8
> > .Cells(1).PasteSpecial Paste:=xlPasteValues
> > .Cells(1).PasteSpecial Paste:=xlPasteFormats
> > .Cells(1).Select
> > Application.CutCopyMode = False
> > End With
> >
> > TempFilePath = Environ$("temp") & "\"
> > TempFileName = "Selection of " & wb.Name & " " _
> > & Format(Now, "dd-mmm-yy h-mm-ss")
> >
> > If Val(Application.Version) < 12 Then
> > 'You use Excel 2000-2003
> > FileExtStr = ".xls": FileFormatNum = -4143
> > Else
> > 'You use Excel 2007
> > FileExtStr = ".xlsx": FileFormatNum = 51
> > End If
> >
> > With Dest
> >
> > .SaveAs TempFilePath & TempFileName & FileExtStr, _
> > FileFormat:=FileFormatNum
> > On Error Resume Next
> > .SendMail "rondebruin@kabelfoon.nl", _
> > "This is the Subject line"
> > On Error GoTo 0
> > .Close SaveChanges:=False
> > End With
> >
> > Kill TempFilePath & TempFileName & FileExtStr
> >
> > With Application
> > .ScreenUpdating = True
> > .EnableEvents = True
> > End With
> > End Sub
> >
> > Function LastRow(sh As Worksheet)
> > On Error Resume Next
> > LastRow = sh.Cells.Find(What:="*", _
> > After:=sh.Range("A1"), _
> > Lookat:=xlPart, _
> > LookIn:=xlFormulas, _
> > SearchOrder:=xlByRows, _
> > SearchDirection:=xlPrevious, _
> > MatchCase:=False).Row
> > On Error GoTo 0
> > End Function
> >
> >
> >
> > "sam" <sam@discussions.microsoft.com> schreef in bericht
> > news:72EF3B4A-476D-4239-ACA9-1D273BD8B180@microsoft.com...
> >> Thanks for your reply Ron,
> >> I have 26 cells of data in a row that I need to mail, from A to Z, I have
> >> to
> >> send it as an excel attachment.
> >>
> >> Thanks in advance
> >>
> >> "Ron de Bruin" wrote:
> >>
> >>> Hi Sam
> >>>
> >>> How many cells with data have a row ?
> >>>
> >>> Do you want to send it in the body or in a workbook
> >>>
> >>>
> >>> "sam" <sam@discussions.microsoft.com> schreef in bericht
> >>> news:85987E9F-C95C-470C-A063-A9583C53B3B4@microsoft.com...
> >>> > Hi All,
> >>> >
> >>> > I have a userform that accepts user inputs and emails it to me once
> >>> > users
> >>> > click "Submit" on the userform. Before being emailed they are stored
> >>> > in a
> >>> > workbook on a shared drive.
> >>> >
> >>> > What is happening is: this workbook that is emailed to me stores the
> >>> > user
> >>> > inputs of each user in a separate row, and hence I am receiving the
> >>> > whole
> >>> > workbook with inputs of all the users.
> >>> >
> >>> > What I want: I want to receive just the current user???s data. I dont
> >>> > want
> >>> > to
> >>> > receive the entire workbook, but the data that has been inputted by
> >>> > the
> >>> > last
> >>> > user only. (For e.g. only the last row updated in the workbook) and
> >>> > not
> >>> > whole
> >>> > workbook.
> >>> >
> >>> > Is there some code I can put in that will email me just the last user
> >>> > input
> >>> > and not the previous inputs?
> >>> >
> >>> > Please help
> >>> > I hope I made it clear
> >>> >
> >>> > Thanks in Advance
> >>> >
> >>> > __________ Information from ESET Smart Security, version of virus
> >>> > signature database 4285 (20090728) __________
> >>> >
> >>> > The message was checked by ESET Smart Security.
> >>> >
> >>> > http://ww...
> >>> >
> >>> >
> >>> >
> >>>
> >>>
> >>> __________ Information from ESET Smart Security, version of virus
> >>> signature database 4285 (20090728) __________
> >>>
> >>> The message was checked by ESET Smart Security.
> >>>
> >>> http://ww...
> >>>
> >>>
> >>>
> >>>
> >>
> >> __________ Information from ESET Smart Security, version of virus
> >> signature database 4285 (20090728) __________
> >>
> >> The message was checked by ESET Smart Security.
> >>
> >> http://ww...
> >>
> >>
> >>
> >
> >
> > __________ Information from ESET Smart Security, version of virus
> > signature database 4285 (20090728) __________
> >
> > The message was checked by ESET Smart Security.
> >
> > http://ww...
> >
> >
> >
>
>
> __________ Information from ESET Smart Security, version of virus signature database 4285 (20090728) __________
>
> The message was checked by ESET Smart Security.
>
> http://ww...
>
>
>
>

Ron de Bruin

7/28/2009 5:30:00 PM

0

Use this then and read this page about the warning
http://www.rondebruin.nl/mail/p...

If you use Outlook you can also add body text if you want
See
http://www.rondebruin.nl/se...


Sub Mail_Range()
'Working in 2000-2007
Dim Source1 As Range
Dim Source2 As Range
Dim Dest As Workbook
Dim wb As Workbook
Dim TempFilePath As String
Dim TempFileName As String
Dim FileExtStr As String
Dim FileFormatNum As Long
Dim Lrow As Long

Lrow = LastRow(ActiveSheet)

On Error Resume Next
Set Source1 = Range("A1:K1")
On Error GoTo 0

On Error Resume Next
Set Source2 = Range("A" & Lrow & ":K" & Lrow)
On Error GoTo 0


With Application
.ScreenUpdating = False
.EnableEvents = False
End With

Set wb = ActiveWorkbook
Set Dest = Workbooks.Add(xlWBATWorksheet)

Source1.Copy
With Dest.Sheets(1)
.Cells(1).PasteSpecial Paste:=8
.Cells(1).PasteSpecial Paste:=xlPasteValues
.Cells(1).PasteSpecial Paste:=xlPasteFormats
.Cells(1).Select
Application.CutCopyMode = False
End With

Source2.Copy
With Dest.Sheets(1)
.Cells(2, 1).PasteSpecial Paste:=8
.Cells(2, 1).PasteSpecial Paste:=xlPasteValues
.Cells(2, 1).PasteSpecial Paste:=xlPasteFormats
.Cells(2, 1).Select
Application.CutCopyMode = False
End With

TempFilePath = Environ$("temp") & "\"
TempFileName = "Selection of " & wb.Name & " " _
& Format(Now, "dd-mmm-yy h-mm-ss")

If Val(Application.Version) < 12 Then
'You use Excel 2000-2003
FileExtStr = ".xls": FileFormatNum = -4143
Else
'You use Excel 2007
FileExtStr = ".xlsx": FileFormatNum = 51
End If

With Dest

.SaveAs TempFilePath & TempFileName & FileExtStr, _
FileFormat:=FileFormatNum
On Error Resume Next
.SendMail "rondebruin@kabelfoon.nl", _
"This is the Subject line"
On Error GoTo 0
.Close SaveChanges:=False
End With

Kill TempFilePath & TempFileName & FileExtStr

With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub

Function LastRow(sh As Worksheet)
On Error Resume Next
LastRow = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
On Error GoTo 0
End Function



"sam" <sam@discussions.microsoft.com> schreef in bericht
news:93CE027D-3299-4321-83BE-E27C103BDDF4@microsoft.com...
> Hey Ron, This worked out great. Thanks a Lot for your help.
> One thing I also wanted was to mail column headers with the last updated
> row.. The first row contains column headers and I would like to mail that
> as
> well.
> I tried updaing this part of the code:
>
> Set Source = Range("A" & Lrow & ":K" &
> Lrow).SpecialCells(xlCellTypeVisible)
>
> to:
>
> Set Source = Range("A" & Lrow & ":K" & Lrow &
> Frow).SpecialCells(xlCellTypeVisible)
>
> But it didnt mail the first row, ALso when I it mails, it asks me to allow
> or deny the macro to mail the book, should I set
> Application.DisplayAlerts =
> False ?
>
> Thanks a lot again.
>
>
> "Ron de Bruin" wrote:
>
>> Change the mail address to yours before you test it
>>
>>
>> "Ron de Bruin" <rondebruin@kabelfoon.nl> schreef in bericht
>> news:%23hQpB15DKHA.4064@TK2MSFTNGP04.phx.gbl...
>> > Hi Sam
>> >
>> > Try this
>> >
>> > Sub Mail_Range()
>> > 'Working in 2000-2007
>> > Dim Source As Range
>> > Dim Dest As Workbook
>> > Dim wb As Workbook
>> > Dim TempFilePath As String
>> > Dim TempFileName As String
>> > Dim FileExtStr As String
>> > Dim FileFormatNum As Long
>> > Dim Lrow As Long
>> >
>> > Lrow = LastRow(ActiveSheet)
>> >
>> > Set Source = Nothing
>> > On Error Resume Next
>> > Set Source = Range("A" & Lrow & ":K" &
>> > Lrow).SpecialCells(xlCellTypeVisible)
>> > On Error GoTo 0
>> >
>> > If Source Is Nothing Then
>> > MsgBox "The source is not a range or the sheet is protected, " &
>> > _
>> > "please correct and try again.", vbOKOnly
>> > Exit Sub
>> > End If
>> >
>> > With Application
>> > .ScreenUpdating = False
>> > .EnableEvents = False
>> > End With
>> >
>> > Set wb = ActiveWorkbook
>> > Set Dest = Workbooks.Add(xlWBATWorksheet)
>> >
>> > Source.Copy
>> > With Dest.Sheets(1)
>> > .Cells(1).PasteSpecial Paste:=8
>> > .Cells(1).PasteSpecial Paste:=xlPasteValues
>> > .Cells(1).PasteSpecial Paste:=xlPasteFormats
>> > .Cells(1).Select
>> > Application.CutCopyMode = False
>> > End With
>> >
>> > TempFilePath = Environ$("temp") & "\"
>> > TempFileName = "Selection of " & wb.Name & " " _
>> > & Format(Now, "dd-mmm-yy h-mm-ss")
>> >
>> > If Val(Application.Version) < 12 Then
>> > 'You use Excel 2000-2003
>> > FileExtStr = ".xls": FileFormatNum = -4143
>> > Else
>> > 'You use Excel 2007
>> > FileExtStr = ".xlsx": FileFormatNum = 51
>> > End If
>> >
>> > With Dest
>> >
>> > .SaveAs TempFilePath & TempFileName & FileExtStr, _
>> > FileFormat:=FileFormatNum
>> > On Error Resume Next
>> > .SendMail "rondebruin@kabelfoon.nl", _
>> > "This is the Subject line"
>> > On Error GoTo 0
>> > .Close SaveChanges:=False
>> > End With
>> >
>> > Kill TempFilePath & TempFileName & FileExtStr
>> >
>> > With Application
>> > .ScreenUpdating = True
>> > .EnableEvents = True
>> > End With
>> > End Sub
>> >
>> > Function LastRow(sh As Worksheet)
>> > On Error Resume Next
>> > LastRow = sh.Cells.Find(What:="*", _
>> > After:=sh.Range("A1"), _
>> > Lookat:=xlPart, _
>> > LookIn:=xlFormulas, _
>> > SearchOrder:=xlByRows, _
>> > SearchDirection:=xlPrevious, _
>> > MatchCase:=False).Row
>> > On Error GoTo 0
>> > End Function
>> >
>> >
>> >
>> > "sam" <sam@discussions.microsoft.com> schreef in bericht
>> > news:72EF3B4A-476D-4239-ACA9-1D273BD8B180@microsoft.com...
>> >> Thanks for your reply Ron,
>> >> I have 26 cells of data in a row that I need to mail, from A to Z, I
>> >> have
>> >> to
>> >> send it as an excel attachment.
>> >>
>> >> Thanks in advance
>> >>
>> >> "Ron de Bruin" wrote:
>> >>
>> >>> Hi Sam
>> >>>
>> >>> How many cells with data have a row ?
>> >>>
>> >>> Do you want to send it in the body or in a workbook
>> >>>
>> >>>
>> >>> "sam" <sam@discussions.microsoft.com> schreef in bericht
>> >>> news:85987E9F-C95C-470C-A063-A9583C53B3B4@microsoft.com...
>> >>> > Hi All,
>> >>> >
>> >>> > I have a userform that accepts user inputs and emails it to me once
>> >>> > users
>> >>> > click "Submit" on the userform. Before being emailed they are
>> >>> > stored
>> >>> > in a
>> >>> > workbook on a shared drive.
>> >>> >
>> >>> > What is happening is: this workbook that is emailed to me stores
>> >>> > the
>> >>> > user
>> >>> > inputs of each user in a separate row, and hence I am receiving the
>> >>> > whole
>> >>> > workbook with inputs of all the users.
>> >>> >
>> >>> > What I want: I want to receive just the current user???s data. I dont
>> >>> > want
>> >>> > to
>> >>> > receive the entire workbook, but the data that has been inputted by
>> >>> > the
>> >>> > last
>> >>> > user only. (For e.g. only the last row updated in the workbook) and
>> >>> > not
>> >>> > whole
>> >>> > workbook.
>> >>> >
>> >>> > Is there some code I can put in that will email me just the last
>> >>> > user
>> >>> > input
>> >>> > and not the previous inputs?
>> >>> >
>> >>> > Please help
>> >>> > I hope I made it clear
>> >>> >
>> >>> > Thanks in Advance
>> >>> >
>> >>> > __________ Information from ESET Smart Security, version of virus
>> >>> > signature database 4285 (20090728) __________
>> >>> >
>> >>> > The message was checked by ESET Smart Security.
>> >>> >
>> >>> > http://ww...
>> >>> >
>> >>> >
>> >>> >
>> >>>
>> >>>
>> >>> __________ Information from ESET Smart Security, version of virus
>> >>> signature database 4285 (20090728) __________
>> >>>
>> >>> The message was checked by ESET Smart Security.
>> >>>
>> >>> http://ww...
>> >>>
>> >>>
>> >>>
>> >>>
>> >>
>> >> __________ Information from ESET Smart Security, version of virus
>> >> signature database 4285 (20090728) __________
>> >>
>> >> The message was checked by ESET Smart Security.
>> >>
>> >> http://ww...
>> >>
>> >>
>> >>
>> >
>> >
>> > __________ Information from ESET Smart Security, version of virus
>> > signature database 4285 (20090728) __________
>> >
>> > The message was checked by ESET Smart Security.
>> >
>> > http://ww...
>> >
>> >
>> >
>>
>>
>> __________ Information from ESET Smart Security, version of virus
>> signature database 4285 (20090728) __________
>>
>> The message was checked by ESET Smart Security.
>>
>> http://ww...
>>
>>
>>
>>
>
> __________ Information from ESET Smart Security, version of virus
> signature database 4285 (20090728) __________
>
> The message was checked by ESET Smart Security.
>
> http://ww...
>
>
>


__________ Information from ESET Smart Security, version of virus signature database 4285 (20090728) __________

The message was checked by ESET Smart Security.

http://ww...



sam

7/28/2009 6:35:00 PM

0

Thank you for all your help, it worked out great. I have to tweak the code a
little to make it work my way, thank you for your sources available online.

"Ron de Bruin" wrote:

> Use this then and read this page about the warning
> http://www.rondebruin.nl/mail/p...
>
> If you use Outlook you can also add body text if you want
> See
> http://www.rondebruin.nl/se...
>
>
> Sub Mail_Range()
> 'Working in 2000-2007
> Dim Source1 As Range
> Dim Source2 As Range
> Dim Dest As Workbook
> Dim wb As Workbook
> Dim TempFilePath As String
> Dim TempFileName As String
> Dim FileExtStr As String
> Dim FileFormatNum As Long
> Dim Lrow As Long
>
> Lrow = LastRow(ActiveSheet)
>
> On Error Resume Next
> Set Source1 = Range("A1:K1")
> On Error GoTo 0
>
> On Error Resume Next
> Set Source2 = Range("A" & Lrow & ":K" & Lrow)
> On Error GoTo 0
>
>
> With Application
> .ScreenUpdating = False
> .EnableEvents = False
> End With
>
> Set wb = ActiveWorkbook
> Set Dest = Workbooks.Add(xlWBATWorksheet)
>
> Source1.Copy
> With Dest.Sheets(1)
> .Cells(1).PasteSpecial Paste:=8
> .Cells(1).PasteSpecial Paste:=xlPasteValues
> .Cells(1).PasteSpecial Paste:=xlPasteFormats
> .Cells(1).Select
> Application.CutCopyMode = False
> End With
>
> Source2.Copy
> With Dest.Sheets(1)
> .Cells(2, 1).PasteSpecial Paste:=8
> .Cells(2, 1).PasteSpecial Paste:=xlPasteValues
> .Cells(2, 1).PasteSpecial Paste:=xlPasteFormats
> .Cells(2, 1).Select
> Application.CutCopyMode = False
> End With
>
> TempFilePath = Environ$("temp") & "\"
> TempFileName = "Selection of " & wb.Name & " " _
> & Format(Now, "dd-mmm-yy h-mm-ss")
>
> If Val(Application.Version) < 12 Then
> 'You use Excel 2000-2003
> FileExtStr = ".xls": FileFormatNum = -4143
> Else
> 'You use Excel 2007
> FileExtStr = ".xlsx": FileFormatNum = 51
> End If
>
> With Dest
>
> .SaveAs TempFilePath & TempFileName & FileExtStr, _
> FileFormat:=FileFormatNum
> On Error Resume Next
> .SendMail "rondebruin@kabelfoon.nl", _
> "This is the Subject line"
> On Error GoTo 0
> .Close SaveChanges:=False
> End With
>
> Kill TempFilePath & TempFileName & FileExtStr
>
> With Application
> .ScreenUpdating = True
> .EnableEvents = True
> End With
> End Sub
>
> Function LastRow(sh As Worksheet)
> On Error Resume Next
> LastRow = sh.Cells.Find(What:="*", _
> After:=sh.Range("A1"), _
> Lookat:=xlPart, _
> LookIn:=xlFormulas, _
> SearchOrder:=xlByRows, _
> SearchDirection:=xlPrevious, _
> MatchCase:=False).Row
> On Error GoTo 0
> End Function
>
>
>
> "sam" <sam@discussions.microsoft.com> schreef in bericht
> news:93CE027D-3299-4321-83BE-E27C103BDDF4@microsoft.com...
> > Hey Ron, This worked out great. Thanks a Lot for your help.
> > One thing I also wanted was to mail column headers with the last updated
> > row.. The first row contains column headers and I would like to mail that
> > as
> > well.
> > I tried updaing this part of the code:
> >
> > Set Source = Range("A" & Lrow & ":K" &
> > Lrow).SpecialCells(xlCellTypeVisible)
> >
> > to:
> >
> > Set Source = Range("A" & Lrow & ":K" & Lrow &
> > Frow).SpecialCells(xlCellTypeVisible)
> >
> > But it didnt mail the first row, ALso when I it mails, it asks me to allow
> > or deny the macro to mail the book, should I set
> > Application.DisplayAlerts =
> > False ?
> >
> > Thanks a lot again.
> >
> >
> > "Ron de Bruin" wrote:
> >
> >> Change the mail address to yours before you test it
> >>
> >>
> >> "Ron de Bruin" <rondebruin@kabelfoon.nl> schreef in bericht
> >> news:%23hQpB15DKHA.4064@TK2MSFTNGP04.phx.gbl...
> >> > Hi Sam
> >> >
> >> > Try this
> >> >
> >> > Sub Mail_Range()
> >> > 'Working in 2000-2007
> >> > Dim Source As Range
> >> > Dim Dest As Workbook
> >> > Dim wb As Workbook
> >> > Dim TempFilePath As String
> >> > Dim TempFileName As String
> >> > Dim FileExtStr As String
> >> > Dim FileFormatNum As Long
> >> > Dim Lrow As Long
> >> >
> >> > Lrow = LastRow(ActiveSheet)
> >> >
> >> > Set Source = Nothing
> >> > On Error Resume Next
> >> > Set Source = Range("A" & Lrow & ":K" &
> >> > Lrow).SpecialCells(xlCellTypeVisible)
> >> > On Error GoTo 0
> >> >
> >> > If Source Is Nothing Then
> >> > MsgBox "The source is not a range or the sheet is protected, " &
> >> > _
> >> > "please correct and try again.", vbOKOnly
> >> > Exit Sub
> >> > End If
> >> >
> >> > With Application
> >> > .ScreenUpdating = False
> >> > .EnableEvents = False
> >> > End With
> >> >
> >> > Set wb = ActiveWorkbook
> >> > Set Dest = Workbooks.Add(xlWBATWorksheet)
> >> >
> >> > Source.Copy
> >> > With Dest.Sheets(1)
> >> > .Cells(1).PasteSpecial Paste:=8
> >> > .Cells(1).PasteSpecial Paste:=xlPasteValues
> >> > .Cells(1).PasteSpecial Paste:=xlPasteFormats
> >> > .Cells(1).Select
> >> > Application.CutCopyMode = False
> >> > End With
> >> >
> >> > TempFilePath = Environ$("temp") & "\"
> >> > TempFileName = "Selection of " & wb.Name & " " _
> >> > & Format(Now, "dd-mmm-yy h-mm-ss")
> >> >
> >> > If Val(Application.Version) < 12 Then
> >> > 'You use Excel 2000-2003
> >> > FileExtStr = ".xls": FileFormatNum = -4143
> >> > Else
> >> > 'You use Excel 2007
> >> > FileExtStr = ".xlsx": FileFormatNum = 51
> >> > End If
> >> >
> >> > With Dest
> >> >
> >> > .SaveAs TempFilePath & TempFileName & FileExtStr, _
> >> > FileFormat:=FileFormatNum
> >> > On Error Resume Next
> >> > .SendMail "rondebruin@kabelfoon.nl", _
> >> > "This is the Subject line"
> >> > On Error GoTo 0
> >> > .Close SaveChanges:=False
> >> > End With
> >> >
> >> > Kill TempFilePath & TempFileName & FileExtStr
> >> >
> >> > With Application
> >> > .ScreenUpdating = True
> >> > .EnableEvents = True
> >> > End With
> >> > End Sub
> >> >
> >> > Function LastRow(sh As Worksheet)
> >> > On Error Resume Next
> >> > LastRow = sh.Cells.Find(What:="*", _
> >> > After:=sh.Range("A1"), _
> >> > Lookat:=xlPart, _
> >> > LookIn:=xlFormulas, _
> >> > SearchOrder:=xlByRows, _
> >> > SearchDirection:=xlPrevious, _
> >> > MatchCase:=False).Row
> >> > On Error GoTo 0
> >> > End Function
> >> >
> >> >
> >> >
> >> > "sam" <sam@discussions.microsoft.com> schreef in bericht
> >> > news:72EF3B4A-476D-4239-ACA9-1D273BD8B180@microsoft.com...
> >> >> Thanks for your reply Ron,
> >> >> I have 26 cells of data in a row that I need to mail, from A to Z, I
> >> >> have
> >> >> to
> >> >> send it as an excel attachment.
> >> >>
> >> >> Thanks in advance
> >> >>
> >> >> "Ron de Bruin" wrote:
> >> >>
> >> >>> Hi Sam
> >> >>>
> >> >>> How many cells with data have a row ?
> >> >>>
> >> >>> Do you want to send it in the body or in a workbook
> >> >>>
> >> >>>
> >> >>> "sam" <sam@discussions.microsoft.com> schreef in bericht
> >> >>> news:85987E9F-C95C-470C-A063-A9583C53B3B4@microsoft.com...
> >> >>> > Hi All,
> >> >>> >
> >> >>> > I have a userform that accepts user inputs and emails it to me once
> >> >>> > users
> >> >>> > click "Submit" on the userform. Before being emailed they are
> >> >>> > stored
> >> >>> > in a
> >> >>> > workbook on a shared drive.
> >> >>> >
> >> >>> > What is happening is: this workbook that is emailed to me stores
> >> >>> > the
> >> >>> > user
> >> >>> > inputs of each user in a separate row, and hence I am receiving the
> >> >>> > whole
> >> >>> > workbook with inputs of all the users.
> >> >>> >
> >> >>> > What I want: I want to receive just the current user???s data. I dont
> >> >>> > want
> >> >>> > to
> >> >>> > receive the entire workbook, but the data that has been inputted by
> >> >>> > the
> >> >>> > last
> >> >>> > user only. (For e.g. only the last row updated in the workbook) and
> >> >>> > not
> >> >>> > whole
> >> >>> > workbook.
> >> >>> >
> >> >>> > Is there some code I can put in that will email me just the last
> >> >>> > user
> >> >>> > input
> >> >>> > and not the previous inputs?
> >> >>> >
> >> >>> > Please help
> >> >>> > I hope I made it clear
> >> >>> >
> >> >>> > Thanks in Advance
> >> >>> >
> >> >>> > __________ Information from ESET Smart Security, version of virus
> >> >>> > signature database 4285 (20090728) __________
> >> >>> >
> >> >>> > The message was checked by ESET Smart Security.
> >> >>> >
> >> >>> > http://ww...
> >> >>> >
> >> >>> >
> >> >>> >
> >> >>>
> >> >>>
> >> >>> __________ Information from ESET Smart Security, version of virus
> >> >>> signature database 4285 (20090728) __________
> >> >>>
> >> >>> The message was checked by ESET Smart Security.
> >> >>>

Ron de Bruin

7/28/2009 6:47:00 PM

0

You are welcome



--

Regards Ron de Bruin
http://www.rondebruin.n...


"sam" <sam@discussions.microsoft.com> schreef in bericht
news:1CD297FF-7E83-4E7B-870C-07249C032C72@microsoft.com...
> Thank you for all your help, it worked out great. I have to tweak the code
> a
> little to make it work my way, thank you for your sources available
> online.
>
> "Ron de Bruin" wrote:
>
>> Use this then and read this page about the warning
>> http://www.rondebruin.nl/mail/p...
>>
>> If you use Outlook you can also add body text if you want
>> See
>> http://www.rondebruin.nl/se...
>>
>>
>> Sub Mail_Range()
>> 'Working in 2000-2007
>> Dim Source1 As Range
>> Dim Source2 As Range
>> Dim Dest As Workbook
>> Dim wb As Workbook
>> Dim TempFilePath As String
>> Dim TempFileName As String
>> Dim FileExtStr As String
>> Dim FileFormatNum As Long
>> Dim Lrow As Long
>>
>> Lrow = LastRow(ActiveSheet)
>>
>> On Error Resume Next
>> Set Source1 = Range("A1:K1")
>> On Error GoTo 0
>>
>> On Error Resume Next
>> Set Source2 = Range("A" & Lrow & ":K" & Lrow)
>> On Error GoTo 0
>>
>>
>> With Application
>> .ScreenUpdating = False
>> .EnableEvents = False
>> End With
>>
>> Set wb = ActiveWorkbook
>> Set Dest = Workbooks.Add(xlWBATWorksheet)
>>
>> Source1.Copy
>> With Dest.Sheets(1)
>> .Cells(1).PasteSpecial Paste:=8
>> .Cells(1).PasteSpecial Paste:=xlPasteValues
>> .Cells(1).PasteSpecial Paste:=xlPasteFormats
>> .Cells(1).Select
>> Application.CutCopyMode = False
>> End With
>>
>> Source2.Copy
>> With Dest.Sheets(1)
>> .Cells(2, 1).PasteSpecial Paste:=8
>> .Cells(2, 1).PasteSpecial Paste:=xlPasteValues
>> .Cells(2, 1).PasteSpecial Paste:=xlPasteFormats
>> .Cells(2, 1).Select
>> Application.CutCopyMode = False
>> End With
>>
>> TempFilePath = Environ$("temp") & "\"
>> TempFileName = "Selection of " & wb.Name & " " _
>> & Format(Now, "dd-mmm-yy h-mm-ss")
>>
>> If Val(Application.Version) < 12 Then
>> 'You use Excel 2000-2003
>> FileExtStr = ".xls": FileFormatNum = -4143
>> Else
>> 'You use Excel 2007
>> FileExtStr = ".xlsx": FileFormatNum = 51
>> End If
>>
>> With Dest
>>
>> .SaveAs TempFilePath & TempFileName & FileExtStr, _
>> FileFormat:=FileFormatNum
>> On Error Resume Next
>> .SendMail "rondebruin@kabelfoon.nl", _
>> "This is the Subject line"
>> On Error GoTo 0
>> .Close SaveChanges:=False
>> End With
>>
>> Kill TempFilePath & TempFileName & FileExtStr
>>
>> With Application
>> .ScreenUpdating = True
>> .EnableEvents = True
>> End With
>> End Sub
>>
>> Function LastRow(sh As Worksheet)
>> On Error Resume Next
>> LastRow = sh.Cells.Find(What:="*", _
>> After:=sh.Range("A1"), _
>> Lookat:=xlPart, _
>> LookIn:=xlFormulas, _
>> SearchOrder:=xlByRows, _
>> SearchDirection:=xlPrevious, _
>> MatchCase:=False).Row
>> On Error GoTo 0
>> End Function
>>
>>
>>
>> "sam" <sam@discussions.microsoft.com> schreef in bericht
>> news:93CE027D-3299-4321-83BE-E27C103BDDF4@microsoft.com...
>> > Hey Ron, This worked out great. Thanks a Lot for your help.
>> > One thing I also wanted was to mail column headers with the last
>> > updated
>> > row.. The first row contains column headers and I would like to mail
>> > that
>> > as
>> > well.
>> > I tried updaing this part of the code:
>> >
>> > Set Source = Range("A" & Lrow & ":K" &
>> > Lrow).SpecialCells(xlCellTypeVisible)
>> >
>> > to:
>> >
>> > Set Source = Range("A" & Lrow & ":K" & Lrow &
>> > Frow).SpecialCells(xlCellTypeVisible)
>> >
>> > But it didnt mail the first row, ALso when I it mails, it asks me to
>> > allow
>> > or deny the macro to mail the book, should I set
>> > Application.DisplayAlerts =
>> > False ?
>> >
>> > Thanks a lot again.
>> >
>> >
>> > "Ron de Bruin" wrote:
>> >
>> >> Change the mail address to yours before you test it
>> >>
>> >>
>> >> "Ron de Bruin" <rondebruin@kabelfoon.nl> schreef in bericht
>> >> news:%23hQpB15DKHA.4064@TK2MSFTNGP04.phx.gbl...
>> >> > Hi Sam
>> >> >
>> >> > Try this
>> >> >
>> >> > Sub Mail_Range()
>> >> > 'Working in 2000-2007
>> >> > Dim Source As Range
>> >> > Dim Dest As Workbook
>> >> > Dim wb As Workbook
>> >> > Dim TempFilePath As String
>> >> > Dim TempFileName As String
>> >> > Dim FileExtStr As String
>> >> > Dim FileFormatNum As Long
>> >> > Dim Lrow As Long
>> >> >
>> >> > Lrow = LastRow(ActiveSheet)
>> >> >
>> >> > Set Source = Nothing
>> >> > On Error Resume Next
>> >> > Set Source = Range("A" & Lrow & ":K" &
>> >> > Lrow).SpecialCells(xlCellTypeVisible)
>> >> > On Error GoTo 0
>> >> >
>> >> > If Source Is Nothing Then
>> >> > MsgBox "The source is not a range or the sheet is protected,
>> >> > " &
>> >> > _
>> >> > "please correct and try again.", vbOKOnly
>> >> > Exit Sub
>> >> > End If
>> >> >
>> >> > With Application
>> >> > .ScreenUpdating = False
>> >> > .EnableEvents = False
>> >> > End With
>> >> >
>> >> > Set wb = ActiveWorkbook
>> >> > Set Dest = Workbooks.Add(xlWBATWorksheet)
>> >> >
>> >> > Source.Copy
>> >> > With Dest.Sheets(1)
>> >> > .Cells(1).PasteSpecial Paste:=8
>> >> > .Cells(1).PasteSpecial Paste:=xlPasteValues
>> >> > .Cells(1).PasteSpecial Paste:=xlPasteFormats
>> >> > .Cells(1).Select
>> >> > Application.CutCopyMode = False
>> >> > End With
>> >> >
>> >> > TempFilePath = Environ$("temp") & "\"
>> >> > TempFileName = "Selection of " & wb.Name & " " _
>> >> > & Format(Now, "dd-mmm-yy h-mm-ss")
>> >> >
>> >> > If Val(Application.Version) < 12 Then
>> >> > 'You use Excel 2000-2003
>> >> > FileExtStr = ".xls": FileFormatNum = -4143
>> >> > Else
>> >> > 'You use Excel 2007
>> >> > FileExtStr = ".xlsx": FileFormatNum = 51
>> >> > End If
>> >> >
>> >> > With Dest
>> >> >
>> >> > .SaveAs TempFilePath & TempFileName & FileExtStr, _
>> >> > FileFormat:=FileFormatNum
>> >> > On Error Resume Next
>> >> > .SendMail "rondebruin@kabelfoon.nl", _
>> >> > "This is the Subject line"
>> >> > On Error GoTo 0
>> >> > .Close SaveChanges:=False
>> >> > End With
>> >> >
>> >> > Kill TempFilePath & TempFileName & FileExtStr
>> >> >
>> >> > With Application
>> >> > .ScreenUpdating = True
>> >> > .EnableEvents = True
>> >> > End With
>> >> > End Sub
>> >> >
>> >> > Function LastRow(sh As Worksheet)
>> >> > On Error Resume Next
>> >> > LastRow = sh.Cells.Find(What:="*", _
>> >> > After:=sh.Range("A1"), _
>> >> > Lookat:=xlPart, _
>> >> > LookIn:=xlFormulas, _
>> >> > SearchOrder:=xlByRows, _
>> >> > SearchDirection:=xlPrevious, _
>> >> > MatchCase:=False).Row
>> >> > On Error GoTo 0
>> >> > End Function
>> >> >
>> >> >
>> >> >
>> >> > "sam" <sam@discussions.microsoft.com> schreef in bericht
>> >> > news:72EF3B4A-476D-4239-ACA9-1D273BD8B180@microsoft.com...
>> >> >> Thanks for your reply Ron,
>> >> >> I have 26 cells of data in a row that I need to mail, from A to Z,
>> >> >> I
>> >> >> have
>> >> >> to
>> >> >> send it as an excel attachment.
>> >> >>
>> >> >> Thanks in advance
>> >> >>
>> >> >> "Ron de Bruin" wrote:
>> >> >>
>> >> >>> Hi Sam
>> >> >>>
>> >> >>> How many cells with data have a row ?
>> >> >>>
>> >> >>> Do you want to send it in the body or in a workbook
>> >> >>>
>> >> >>>
>> >> >>> "sam" <sam@discussions.microsoft.com> schreef in bericht
>> >> >>> news:85987E9F-C95C-470C-A063-A9583C53B3B4@microsoft.com...
>> >> >>> > Hi All,
>> >> >>> >
>> >> >>> > I have a userform that accepts user inputs and emails it to me
>> >> >>> > once
>> >> >>> > users
>> >> >>> > click "Submit" on the userform. Before being emailed they are
>> >> >>> > stored
>> >> >>> > in a
>> >> >>> > workbook on a shared drive.
>> >> >>> >
>> >> >>> > What is happening is: this workbook that is emailed to me stores
>> >> >>> > the
>> >> >>> > user
>> >> >>> > inputs of each user in a separate row, and hence I am receiving
>> >> >>> > the
>> >> >>> > whole
>> >> >>> > workbook with inputs of all the users.
>> >> >>> >
>> >> >>> > What I want: I want to receive just the current user???s data. I
>> >> >>> > dont
>> >> >>> > want
>> >> >>> > to
>> >> >>> > receive the entire workbook, but the data that has been inputted
>> >> >>> > by
>> >> >>> > the
>> >> >>> > last
>> >> >>> > user only. (For e.g. only the last row updated in the workbook)
>> >> >>> > and
>> >> >>> > not
>> >> >>> > whole
>> >> >>> > workbook.
>> >> >>> >
>> >> >>> > Is there some code I can put in that will email me just the last
>> >> >>> > user
>> >> >>> > input
>> >> >>> > and not the previous inputs?
>> >> >>> >
>> >> >>> > Please help
>> >> >>> > I hope I made it clear
>> >> >>> >
>> >> >>> > Thanks in Advance
>> >> >>> >
>> >> >>> > __________ Information from ESET Smart Security, version of
>> >> >>> > virus
>> >> >>> > signature database 4285 (20090728) __________
>> >> >>> >
>> >> >>> > The message was checked by ESET Smart Security.
>> >> >>> >
>> >> >>> > http://ww...
>> >> >>> >
>> >> >>> >
>> >> >>> >
>> >> >>>
>> >> >>>
>> >> >>> __________ Information from ESET Smart Security, version of virus
>> >> >>> signature database 4285 (20090728) __________
>> >> >>>
>> >> >>> The message was checked by ESET Smart Security.
>> >> >>>
>
> __________ Information from ESET Smart Security, version of virus
> signature database 4286 (20090728) __________
>
> The message was checked by ESET Smart Security.
>
> http://ww...
>
>
>


__________ Information from ESET Smart Security, version of virus signature database 4286 (20090728) __________

The message was checked by ESET Smart Security.

http://ww...



sam

7/28/2009 7:40:00 PM

0

Hey Ron, Is this approach possible?

1. Saving all User inputs(accepted through userform) in a workbook template,
lets say: UserWb.xls
2. Now, Saving a copy of the same workbook(UserWb.xls) as UserWbCpy.xls with
just he current user entry.
3. Mailing the copy that includes current user entry only(UserWbCpy.xls)
4. Deleting the copy(UserWbCpy.xls).

But the original template still remains(UserWb.xls) as I want to keep a
backup file of all user inputs.

Thanks in advance


"Ron de Bruin" wrote:

> You are welcome
>
>
>
> --
>
> Regards Ron de Bruin
> http://www.rondebruin.n...
>
>
> "sam" <sam@discussions.microsoft.com> schreef in bericht
> news:1CD297FF-7E83-4E7B-870C-07249C032C72@microsoft.com...
> > Thank you for all your help, it worked out great. I have to tweak the code
> > a
> > little to make it work my way, thank you for your sources available
> > online.
> >
> > "Ron de Bruin" wrote:
> >
> >> Use this then and read this page about the warning
> >> http://www.rondebruin.nl/mail/p...
> >>
> >> If you use Outlook you can also add body text if you want
> >> See
> >> http://www.rondebruin.nl/se...
> >>
> >>
> >> Sub Mail_Range()
> >> 'Working in 2000-2007
> >> Dim Source1 As Range
> >> Dim Source2 As Range
> >> Dim Dest As Workbook
> >> Dim wb As Workbook
> >> Dim TempFilePath As String
> >> Dim TempFileName As String
> >> Dim FileExtStr As String
> >> Dim FileFormatNum As Long
> >> Dim Lrow As Long
> >>
> >> Lrow = LastRow(ActiveSheet)
> >>
> >> On Error Resume Next
> >> Set Source1 = Range("A1:K1")
> >> On Error GoTo 0
> >>
> >> On Error Resume Next
> >> Set Source2 = Range("A" & Lrow & ":K" & Lrow)
> >> On Error GoTo 0
> >>
> >>
> >> With Application
> >> .ScreenUpdating = False
> >> .EnableEvents = False
> >> End With
> >>
> >> Set wb = ActiveWorkbook
> >> Set Dest = Workbooks.Add(xlWBATWorksheet)
> >>
> >> Source1.Copy
> >> With Dest.Sheets(1)
> >> .Cells(1).PasteSpecial Paste:=8
> >> .Cells(1).PasteSpecial Paste:=xlPasteValues
> >> .Cells(1).PasteSpecial Paste:=xlPasteFormats
> >> .Cells(1).Select
> >> Application.CutCopyMode = False
> >> End With
> >>
> >> Source2.Copy
> >> With Dest.Sheets(1)
> >> .Cells(2, 1).PasteSpecial Paste:=8
> >> .Cells(2, 1).PasteSpecial Paste:=xlPasteValues
> >> .Cells(2, 1).PasteSpecial Paste:=xlPasteFormats
> >> .Cells(2, 1).Select
> >> Application.CutCopyMode = False
> >> End With
> >>
> >> TempFilePath = Environ$("temp") & "\"
> >> TempFileName = "Selection of " & wb.Name & " " _
> >> & Format(Now, "dd-mmm-yy h-mm-ss")
> >>
> >> If Val(Application.Version) < 12 Then
> >> 'You use Excel 2000-2003
> >> FileExtStr = ".xls": FileFormatNum = -4143
> >> Else
> >> 'You use Excel 2007
> >> FileExtStr = ".xlsx": FileFormatNum = 51
> >> End If
> >>
> >> With Dest
> >>
> >> .SaveAs TempFilePath & TempFileName & FileExtStr, _
> >> FileFormat:=FileFormatNum
> >> On Error Resume Next
> >> .SendMail "rondebruin@kabelfoon.nl", _
> >> "This is the Subject line"
> >> On Error GoTo 0
> >> .Close SaveChanges:=False
> >> End With
> >>
> >> Kill TempFilePath & TempFileName & FileExtStr
> >>
> >> With Application
> >> .ScreenUpdating = True
> >> .EnableEvents = True
> >> End With
> >> End Sub
> >>
> >> Function LastRow(sh As Worksheet)
> >> On Error Resume Next
> >> LastRow = sh.Cells.Find(What:="*", _
> >> After:=sh.Range("A1"), _
> >> Lookat:=xlPart, _
> >> LookIn:=xlFormulas, _
> >> SearchOrder:=xlByRows, _
> >> SearchDirection:=xlPrevious, _
> >> MatchCase:=False).Row
> >> On Error GoTo 0
> >> End Function
> >>
> >>
> >>
> >> "sam" <sam@discussions.microsoft.com> schreef in bericht
> >> news:93CE027D-3299-4321-83BE-E27C103BDDF4@microsoft.com...
> >> > Hey Ron, This worked out great. Thanks a Lot for your help.
> >> > One thing I also wanted was to mail column headers with the last
> >> > updated
> >> > row.. The first row contains column headers and I would like to mail
> >> > that
> >> > as
> >> > well.
> >> > I tried updaing this part of the code:
> >> >
> >> > Set Source = Range("A" & Lrow & ":K" &
> >> > Lrow).SpecialCells(xlCellTypeVisible)
> >> >
> >> > to:
> >> >
> >> > Set Source = Range("A" & Lrow & ":K" & Lrow &
> >> > Frow).SpecialCells(xlCellTypeVisible)
> >> >
> >> > But it didnt mail the first row, ALso when I it mails, it asks me to
> >> > allow
> >> > or deny the macro to mail the book, should I set
> >> > Application.DisplayAlerts =
> >> > False ?
> >> >
> >> > Thanks a lot again.
> >> >
> >> >
> >> > "Ron de Bruin" wrote:
> >> >
> >> >> Change the mail address to yours before you test it
> >> >>
> >> >>
> >> >> "Ron de Bruin" <rondebruin@kabelfoon.nl> schreef in bericht
> >> >> news:%23hQpB15DKHA.4064@TK2MSFTNGP04.phx.gbl...
> >> >> > Hi Sam
> >> >> >
> >> >> > Try this
> >> >> >
> >> >> > Sub Mail_Range()
> >> >> > 'Working in 2000-2007
> >> >> > Dim Source As Range
> >> >> > Dim Dest As Workbook
> >> >> > Dim wb As Workbook
> >> >> > Dim TempFilePath As String
> >> >> > Dim TempFileName As String
> >> >> > Dim FileExtStr As String
> >> >> > Dim FileFormatNum As Long
> >> >> > Dim Lrow As Long
> >> >> >
> >> >> > Lrow = LastRow(ActiveSheet)
> >> >> >
> >> >> > Set Source = Nothing
> >> >> > On Error Resume Next
> >> >> > Set Source = Range("A" & Lrow & ":K" &
> >> >> > Lrow).SpecialCells(xlCellTypeVisible)
> >> >> > On Error GoTo 0
> >> >> >
> >> >> > If Source Is Nothing Then
> >> >> > MsgBox "The source is not a range or the sheet is protected,
> >> >> > " &
> >> >> > _
> >> >> > "please correct and try again.", vbOKOnly
> >> >> > Exit Sub
> >> >> > End If
> >> >> >
> >> >> > With Application
> >> >> > .ScreenUpdating = False
> >> >> > .EnableEvents = False
> >> >> > End With
> >> >> >
> >> >> > Set wb = ActiveWorkbook
> >> >> > Set Dest = Workbooks.Add(xlWBATWorksheet)
> >> >> >
> >> >> > Source.Copy
> >> >> > With Dest.Sheets(1)
> >> >> > .Cells(1).PasteSpecial Paste:=8
> >> >> > .Cells(1).PasteSpecial Paste:=xlPasteValues
> >> >> > .Cells(1).PasteSpecial Paste:=xlPasteFormats
> >> >> > .Cells(1).Select
> >> >> > Application.CutCopyMode = False
> >> >> > End With
> >> >> >
> >> >> > TempFilePath = Environ$("temp") & "\"
> >> >> > TempFileName = "Selection of " & wb.Name & " " _
> >> >> > & Format(Now, "dd-mmm-yy h-mm-ss")
> >> >> >
> >> >> > If Val(Application.Version) < 12 Then
> >> >> > 'You use Excel 2000-2003
> >> >> > FileExtStr = ".xls": FileFormatNum = -4143
> >> >> > Else
> >> >> > 'You use Excel 2007
> >> >> > FileExtStr = ".xlsx": FileFormatNum = 51
> >> >> > End If
> >> >> >
> >> >> > With Dest
> >> >> >
> >> >> > .SaveAs TempFilePath & TempFileName & FileExtStr, _
> >> >> > FileFormat:=FileFormatNum
> >> >> > On Error Resume Next
> >> >> > .SendMail "rondebruin@kabelfoon.nl", _
> >> >> > "This is the Subject line"
> >> >> > On Error GoTo 0
> >> >> > .Close SaveChanges:=False
> >> >> > End With
> >> >> >
> >> >> > Kill TempFilePath & TempFileName & FileExtStr
> >> >> >
> >> >> > With Application
> >> >> > .ScreenUpdating = True
> >> >> > .EnableEvents = True
> >> >> > End With
> >> >> > End Sub
> >> >> >
> >> >> > Function LastRow(sh As Worksheet)
> >> >> > On Error Resume Next
> >> >> > LastRow = sh.Cells.Find(What:="*", _
> >> >> > After:=sh.Range("A1"), _
> >> >> > Lookat:=xlPart, _
> >> >> > LookIn:=xlFormulas, _
> >> >> > SearchOrder:=xlByRows, _
> >> >> > SearchDirection:=xlPrevious, _
> >> >> > MatchCase:=False).Row
> >> >> > On Error GoTo 0
> >> >> > End Function
> >> >> >
> >> >> >
> >> >> >
> >> >> > "sam" <sam@discussions.microsoft.com> schreef in bericht
> >> >> > news:72EF3B4A-476D-4239-ACA9-1D273BD8B180@microsoft.com...
> >> >> >> Thanks for your reply Ron,
> >> >> >> I have 26 cells of data in a row that I need to mail, from A to Z,
> >> >> >> I
> >> >> >> have
> >> >> >> to
> >> >> >> send it as an excel attachment.
> >> >> >>
> >> >> >> Thanks in advance
> >> >> >>
> >> >> >> "Ron de Bruin" wrote:
> >> >> >>
> >> >> >>> Hi Sam
> >> >> >>>
> >> >> >>> How many cells with data have a row ?
> >> >> >>>
> >> >> >>> Do you want to send it in the body or in a workbook
> >> >> >>>
> >> >> >>>
> >> >> >>> "sam" <sam@discussions.microsoft.com> schreef in bericht
> >> >> >>> news:85987E9F-C95C-470C-A063-A9583C53B3B4@microsoft.com...
> >> >> >>> > Hi All,
> >> >> >>> >
> >> >> >>> > I have a userform that accepts user inputs and emails it to me
> >> >> >>> > once
> >> >> >>> > users
> >> >> >>> > click "Submit" on the userform. Before being emailed they are
> >> >> >>> > stored
> >> >> >>> > in a
> >> >> >>> > workbook on a shared drive.
> >> >> >>> >
> >> >> >>> > What is happening is: this workbook that is emailed to me stores
> >> >> >>> > the
> >> >> >>> > user
> >> >> >>> > inputs of each user in a separate row, and hence I am receiving
> >> >> >>> > the
> >> >> >>> > whole
> >> >> >>> > workbook with inputs of all the users.
> >> >> >>> >
> >> >> >>> > What I want: I want to receive just the current user???s data. I
> >> >> >>> > dont
> >> >> >>> > want
> >> >> >>> > to
> >> >> >>> > receive the entire workbook, but the data that has been inputted
> >> >> >>> > by
> >> >> >>> > the
> >> >> >>> > last
> >> >> >>> > user only. (For e.g. only the last row updated in the workbook)
> >> >> >>> > and
> >> >> >>> > not

Ron de Bruin

7/28/2009 7:55:00 PM

0

Hi Sam

That it is doing now

It create a new workbook
Copy the header and last row in it
Save it
Mail it
delete it

Your workbook with the userform is still the same




--

Regards Ron de Bruin
http://www.rondebruin.n...


"sam" <sam@discussions.microsoft.com> schreef in bericht
news:16AE6587-5A3E-4E52-8E73-A76A05BBBF31@microsoft.com...
> Hey Ron, Is this approach possible?
>
> 1. Saving all User inputs(accepted through userform) in a workbook
> template,
> lets say: UserWb.xls
> 2. Now, Saving a copy of the same workbook(UserWb.xls) as UserWbCpy.xls
> with
> just he current user entry.
> 3. Mailing the copy that includes current user entry only(UserWbCpy.xls)
> 4. Deleting the copy(UserWbCpy.xls).
>
> But the original template still remains(UserWb.xls) as I want to keep a
> backup file of all user inputs.
>
> Thanks in advance
>
>
> "Ron de Bruin" wrote:
>
>> You are welcome
>>
>>
>>
>> --
>>
>> Regards Ron de Bruin
>> http://www.rondebruin.n...
>>
>>
>> "sam" <sam@discussions.microsoft.com> schreef in bericht
>> news:1CD297FF-7E83-4E7B-870C-07249C032C72@microsoft.com...
>> > Thank you for all your help, it worked out great. I have to tweak the
>> > code
>> > a
>> > little to make it work my way, thank you for your sources available
>> > online.
>> >
>> > "Ron de Bruin" wrote:
>> >
>> >> Use this then and read this page about the warning
>> >> http://www.rondebruin.nl/mail/p...
>> >>
>> >> If you use Outlook you can also add body text if you want
>> >> See
>> >> http://www.rondebruin.nl/se...
>> >>
>> >>
>> >> Sub Mail_Range()
>> >> 'Working in 2000-2007
>> >> Dim Source1 As Range
>> >> Dim Source2 As Range
>> >> Dim Dest As Workbook
>> >> Dim wb As Workbook
>> >> Dim TempFilePath As String
>> >> Dim TempFileName As String
>> >> Dim FileExtStr As String
>> >> Dim FileFormatNum As Long
>> >> Dim Lrow As Long
>> >>
>> >> Lrow = LastRow(ActiveSheet)
>> >>
>> >> On Error Resume Next
>> >> Set Source1 = Range("A1:K1")
>> >> On Error GoTo 0
>> >>
>> >> On Error Resume Next
>> >> Set Source2 = Range("A" & Lrow & ":K" & Lrow)
>> >> On Error GoTo 0
>> >>
>> >>
>> >> With Application
>> >> .ScreenUpdating = False
>> >> .EnableEvents = False
>> >> End With
>> >>
>> >> Set wb = ActiveWorkbook
>> >> Set Dest = Workbooks.Add(xlWBATWorksheet)
>> >>
>> >> Source1.Copy
>> >> With Dest.Sheets(1)
>> >> .Cells(1).PasteSpecial Paste:=8
>> >> .Cells(1).PasteSpecial Paste:=xlPasteValues
>> >> .Cells(1).PasteSpecial Paste:=xlPasteFormats
>> >> .Cells(1).Select
>> >> Application.CutCopyMode = False
>> >> End With
>> >>
>> >> Source2.Copy
>> >> With Dest.Sheets(1)
>> >> .Cells(2, 1).PasteSpecial Paste:=8
>> >> .Cells(2, 1).PasteSpecial Paste:=xlPasteValues
>> >> .Cells(2, 1).PasteSpecial Paste:=xlPasteFormats
>> >> .Cells(2, 1).Select
>> >> Application.CutCopyMode = False
>> >> End With
>> >>
>> >> TempFilePath = Environ$("temp") & "\"
>> >> TempFileName = "Selection of " & wb.Name & " " _
>> >> & Format(Now, "dd-mmm-yy h-mm-ss")
>> >>
>> >> If Val(Application.Version) < 12 Then
>> >> 'You use Excel 2000-2003
>> >> FileExtStr = ".xls": FileFormatNum = -4143
>> >> Else
>> >> 'You use Excel 2007
>> >> FileExtStr = ".xlsx": FileFormatNum = 51
>> >> End If
>> >>
>> >> With Dest
>> >>
>> >> .SaveAs TempFilePath & TempFileName & FileExtStr, _
>> >> FileFormat:=FileFormatNum
>> >> On Error Resume Next
>> >> .SendMail "rondebruin@kabelfoon.nl", _
>> >> "This is the Subject line"
>> >> On Error GoTo 0
>> >> .Close SaveChanges:=False
>> >> End With
>> >>
>> >> Kill TempFilePath & TempFileName & FileExtStr
>> >>
>> >> With Application
>> >> .ScreenUpdating = True
>> >> .EnableEvents = True
>> >> End With
>> >> End Sub
>> >>
>> >> Function LastRow(sh As Worksheet)
>> >> On Error Resume Next
>> >> LastRow = sh.Cells.Find(What:="*", _
>> >> After:=sh.Range("A1"), _
>> >> Lookat:=xlPart, _
>> >> LookIn:=xlFormulas, _
>> >> SearchOrder:=xlByRows, _
>> >> SearchDirection:=xlPrevious, _
>> >> MatchCase:=False).Row
>> >> On Error GoTo 0
>> >> End Function
>> >>
>> >>
>> >>
>> >> "sam" <sam@discussions.microsoft.com> schreef in bericht
>> >> news:93CE027D-3299-4321-83BE-E27C103BDDF4@microsoft.com...
>> >> > Hey Ron, This worked out great. Thanks a Lot for your help.
>> >> > One thing I also wanted was to mail column headers with the last
>> >> > updated
>> >> > row.. The first row contains column headers and I would like to mail
>> >> > that
>> >> > as
>> >> > well.
>> >> > I tried updaing this part of the code:
>> >> >
>> >> > Set Source = Range("A" & Lrow & ":K" &
>> >> > Lrow).SpecialCells(xlCellTypeVisible)
>> >> >
>> >> > to:
>> >> >
>> >> > Set Source = Range("A" & Lrow & ":K" & Lrow &
>> >> > Frow).SpecialCells(xlCellTypeVisible)
>> >> >
>> >> > But it didnt mail the first row, ALso when I it mails, it asks me to
>> >> > allow
>> >> > or deny the macro to mail the book, should I set
>> >> > Application.DisplayAlerts =
>> >> > False ?
>> >> >
>> >> > Thanks a lot again.
>> >> >
>> >> >
>> >> > "Ron de Bruin" wrote:
>> >> >
>> >> >> Change the mail address to yours before you test it
>> >> >>
>> >> >>
>> >> >> "Ron de Bruin" <rondebruin@kabelfoon.nl> schreef in bericht
>> >> >> news:%23hQpB15DKHA.4064@TK2MSFTNGP04.phx.gbl...
>> >> >> > Hi Sam
>> >> >> >
>> >> >> > Try this
>> >> >> >
>> >> >> > Sub Mail_Range()
>> >> >> > 'Working in 2000-2007
>> >> >> > Dim Source As Range
>> >> >> > Dim Dest As Workbook
>> >> >> > Dim wb As Workbook
>> >> >> > Dim TempFilePath As String
>> >> >> > Dim TempFileName As String
>> >> >> > Dim FileExtStr As String
>> >> >> > Dim FileFormatNum As Long
>> >> >> > Dim Lrow As Long
>> >> >> >
>> >> >> > Lrow = LastRow(ActiveSheet)
>> >> >> >
>> >> >> > Set Source = Nothing
>> >> >> > On Error Resume Next
>> >> >> > Set Source = Range("A" & Lrow & ":K" &
>> >> >> > Lrow).SpecialCells(xlCellTypeVisible)
>> >> >> > On Error GoTo 0
>> >> >> >
>> >> >> > If Source Is Nothing Then
>> >> >> > MsgBox "The source is not a range or the sheet is
>> >> >> > protected,
>> >> >> > " &
>> >> >> > _
>> >> >> > "please correct and try again.", vbOKOnly
>> >> >> > Exit Sub
>> >> >> > End If
>> >> >> >
>> >> >> > With Application
>> >> >> > .ScreenUpdating = False
>> >> >> > .EnableEvents = False
>> >> >> > End With
>> >> >> >
>> >> >> > Set wb = ActiveWorkbook
>> >> >> > Set Dest = Workbooks.Add(xlWBATWorksheet)
>> >> >> >
>> >> >> > Source.Copy
>> >> >> > With Dest.Sheets(1)
>> >> >> > .Cells(1).PasteSpecial Paste:=8
>> >> >> > .Cells(1).PasteSpecial Paste:=xlPasteValues
>> >> >> > .Cells(1).PasteSpecial Paste:=xlPasteFormats
>> >> >> > .Cells(1).Select
>> >> >> > Application.CutCopyMode = False
>> >> >> > End With
>> >> >> >
>> >> >> > TempFilePath = Environ$("temp") & "\"
>> >> >> > TempFileName = "Selection of " & wb.Name & " " _
>> >> >> > & Format(Now, "dd-mmm-yy h-mm-ss")
>> >> >> >
>> >> >> > If Val(Application.Version) < 12 Then
>> >> >> > 'You use Excel 2000-2003
>> >> >> > FileExtStr = ".xls": FileFormatNum = -4143
>> >> >> > Else
>> >> >> > 'You use Excel 2007
>> >> >> > FileExtStr = ".xlsx": FileFormatNum = 51
>> >> >> > End If
>> >> >> >
>> >> >> > With Dest
>> >> >> >
>> >> >> > .SaveAs TempFilePath & TempFileName & FileExtStr, _
>> >> >> > FileFormat:=FileFormatNum
>> >> >> > On Error Resume Next
>> >> >> > .SendMail "rondebruin@kabelfoon.nl", _
>> >> >> > "This is the Subject line"
>> >> >> > On Error GoTo 0
>> >> >> > .Close SaveChanges:=False
>> >> >> > End With
>> >> >> >
>> >> >> > Kill TempFilePath & TempFileName & FileExtStr
>> >> >> >
>> >> >> > With Application
>> >> >> > .ScreenUpdating = True
>> >> >> > .EnableEvents = True
>> >> >> > End With
>> >> >> > End Sub
>> >> >> >
>> >> >> > Function LastRow(sh As Worksheet)
>> >> >> > On Error Resume Next
>> >> >> > LastRow = sh.Cells.Find(What:="*", _
>> >> >> > After:=sh.Range("A1"), _
>> >> >> > Lookat:=xlPart, _
>> >> >> > LookIn:=xlFormulas, _
>> >> >> > SearchOrder:=xlByRows, _
>> >> >> > SearchDirection:=xlPrevious, _
>> >> >> > MatchCase:=False).Row
>> >> >> > On Error GoTo 0
>> >> >> > End Function
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> > "sam" <sam@discussions.microsoft.com> schreef in bericht
>> >> >> > news:72EF3B4A-476D-4239-ACA9-1D273BD8B180@microsoft.com...
>> >> >> >> Thanks for your reply Ron,
>> >> >> >> I have 26 cells of data in a row that I need to mail, from A to
>> >> >> >> Z,
>> >> >> >> I
>> >> >> >> have
>> >> >> >> to
>> >> >> >> send it as an excel attachment.
>> >> >> >>
>> >> >> >> Thanks in advance
>> >> >> >>
>> >> >> >> "Ron de Bruin" wrote:
>> >> >> >>
>> >> >> >>> Hi Sam
>> >> >> >>>
>> >> >> >>> How many cells with data have a row ?
>> >> >> >>>
>> >> >> >>> Do you want to send it in the body or in a workbook
>> >> >> >>>
>> >> >> >>>
>> >> >> >>> "sam" <sam@discussions.microsoft.com> schreef in bericht
>> >> >> >>> news:85987E9F-C95C-470C-A063-A9583C53B3B4@microsoft.com...
>> >> >> >>> > Hi All,
>> >> >> >>> >
>> >> >> >>> > I have a userform that accepts user inputs and emails it to
>> >> >> >>> > me
>> >> >> >>> > once
>> >> >> >>> > users
>> >> >> >>> > click "Submit" on the userform. Before being emailed they are
>> >> >> >>> > stored
>> >> >> >>> > in a
>> >> >> >>> > workbook on a shared drive.
>> >> >> >>> >
>> >> >> >>> > What is happening is: this workbook that is emailed to me
>> >> >> >>> > stores
>> >> >> >>> > the
>> >> >> >>> > user
>> >> >> >>> > inputs of each user in a separate row, and hence I am
>> >> >> >>> > receiving
>> >> >> >>> > the
>> >> >> >>> > whole
>> >> >> >>> > workbook with inputs of all the users.
>> >> >> >>> >
>> >> >> >>> > What I want: I want to receive just the current user???s data.
>> >> >> >>> > I
>> >> >> >>> > dont
>> >> >> >>> > want
>> >> >> >>> > to
>> >> >> >>> > receive the entire workbook, but the data that has been
>> >> >> >>> > inputted
>> >> >> >>> > by
>> >> >> >>> > the
>> >> >> >>> > last
>> >> >> >>> > user only. (For e.g. only the last row updated in the
>> >> >> >>> > workbook)
>> >> >> >>> > and
>> >> >> >>> > not
>
> __________ Information from ESET Smart Security, version of virus
> signature database 4286 (20090728) __________
>
> The message was checked by ESET Smart Security.
>
> http://ww...
>
>
>


__________ Information from ESET Smart Security, version of virus signature database 4286 (20090728) __________

The message was checked by ESET Smart Security.

http://ww...



sam

7/28/2009 8:40:00 PM

0

I think I have messed up your code a litte.. will work on it from start,
I am getting a "run time error, Object required" on this line:

------> Source1.Copy
With Dest.Sheets(1)
.Cells(1).PasteSpecial Paste:=8
.Cells(1).PasteSpecial Paste:=xlPasteValues
.Cells(1).PasteSpecial Paste:=xlPasteFormats
.Cells(1).Select
Application.CutCopyMode = False
End With


I have declared everything and also set my workbook, Here is the code:

Dim Source1 As Range
Dim Source2 As Range
Dim Lrow As Long
Dim TempFilePath As String
Dim TempFileName As String
Dim OutApp As Object
Dim OutMail As Object
Dim Dest As Workbook

Lrow = LastRow(ActiveSheet)

On Error Resume Next
Set Source1 = Range("A1:W1")
On Error GoTo 0

On Error Resume Next
Set Source2 = Range("A" & Lrow & ":W" & Lrow)
On Error GoTo 0

Set Dest = Workbooks.Open(Filename:="H:\Book11.xlsm")

Am i missing something?

Thanks in Advance

"Ron de Bruin" wrote:

> Hi Sam
>
> That it is doing now
>
> It create a new workbook
> Copy the header and last row in it
> Save it
> Mail it
> delete it
>
> Your workbook with the userform is still the same
>
>
>
>
> --
>
> Regards Ron de Bruin
> http://www.rondebruin.n...
>
>
> "sam" <sam@discussions.microsoft.com> schreef in bericht
> news:16AE6587-5A3E-4E52-8E73-A76A05BBBF31@microsoft.com...
> > Hey Ron, Is this approach possible?
> >
> > 1. Saving all User inputs(accepted through userform) in a workbook
> > template,
> > lets say: UserWb.xls
> > 2. Now, Saving a copy of the same workbook(UserWb.xls) as UserWbCpy.xls
> > with
> > just he current user entry.
> > 3. Mailing the copy that includes current user entry only(UserWbCpy.xls)
> > 4. Deleting the copy(UserWbCpy.xls).
> >
> > But the original template still remains(UserWb.xls) as I want to keep a
> > backup file of all user inputs.
> >
> > Thanks in advance
> >
> >
> > "Ron de Bruin" wrote:
> >
> >> You are welcome
> >>
> >>
> >>
> >> --
> >>
> >> Regards Ron de Bruin
> >> http://www.rondebruin.n...
> >>
> >>
> >> "sam" <sam@discussions.microsoft.com> schreef in bericht
> >> news:1CD297FF-7E83-4E7B-870C-07249C032C72@microsoft.com...
> >> > Thank you for all your help, it worked out great. I have to tweak the
> >> > code
> >> > a
> >> > little to make it work my way, thank you for your sources available
> >> > online.
> >> >
> >> > "Ron de Bruin" wrote:
> >> >
> >> >> Use this then and read this page about the warning
> >> >> http://www.rondebruin.nl/mail/p...
> >> >>
> >> >> If you use Outlook you can also add body text if you want
> >> >> See
> >> >> http://www.rondebruin.nl/se...
> >> >>
> >> >>
> >> >> Sub Mail_Range()
> >> >> 'Working in 2000-2007
> >> >> Dim Source1 As Range
> >> >> Dim Source2 As Range
> >> >> Dim Dest As Workbook
> >> >> Dim wb As Workbook
> >> >> Dim TempFilePath As String
> >> >> Dim TempFileName As String
> >> >> Dim FileExtStr As String
> >> >> Dim FileFormatNum As Long
> >> >> Dim Lrow As Long
> >> >>
> >> >> Lrow = LastRow(ActiveSheet)
> >> >>
> >> >> On Error Resume Next
> >> >> Set Source1 = Range("A1:K1")
> >> >> On Error GoTo 0
> >> >>
> >> >> On Error Resume Next
> >> >> Set Source2 = Range("A" & Lrow & ":K" & Lrow)
> >> >> On Error GoTo 0
> >> >>
> >> >>
> >> >> With Application
> >> >> .ScreenUpdating = False
> >> >> .EnableEvents = False
> >> >> End With
> >> >>
> >> >> Set wb = ActiveWorkbook
> >> >> Set Dest = Workbooks.Add(xlWBATWorksheet)
> >> >>
> >> >> Source1.Copy
> >> >> With Dest.Sheets(1)
> >> >> .Cells(1).PasteSpecial Paste:=8
> >> >> .Cells(1).PasteSpecial Paste:=xlPasteValues
> >> >> .Cells(1).PasteSpecial Paste:=xlPasteFormats
> >> >> .Cells(1).Select
> >> >> Application.CutCopyMode = False
> >> >> End With
> >> >>
> >> >> Source2.Copy
> >> >> With Dest.Sheets(1)
> >> >> .Cells(2, 1).PasteSpecial Paste:=8
> >> >> .Cells(2, 1).PasteSpecial Paste:=xlPasteValues
> >> >> .Cells(2, 1).PasteSpecial Paste:=xlPasteFormats
> >> >> .Cells(2, 1).Select
> >> >> Application.CutCopyMode = False
> >> >> End With
> >> >>
> >> >> TempFilePath = Environ$("temp") & "\"
> >> >> TempFileName = "Selection of " & wb.Name & " " _
> >> >> & Format(Now, "dd-mmm-yy h-mm-ss")
> >> >>
> >> >> If Val(Application.Version) < 12 Then
> >> >> 'You use Excel 2000-2003
> >> >> FileExtStr = ".xls": FileFormatNum = -4143
> >> >> Else
> >> >> 'You use Excel 2007
> >> >> FileExtStr = ".xlsx": FileFormatNum = 51
> >> >> End If
> >> >>
> >> >> With Dest
> >> >>
> >> >> .SaveAs TempFilePath & TempFileName & FileExtStr, _
> >> >> FileFormat:=FileFormatNum
> >> >> On Error Resume Next
> >> >> .SendMail "rondebruin@kabelfoon.nl", _
> >> >> "This is the Subject line"
> >> >> On Error GoTo 0
> >> >> .Close SaveChanges:=False
> >> >> End With
> >> >>
> >> >> Kill TempFilePath & TempFileName & FileExtStr
> >> >>
> >> >> With Application
> >> >> .ScreenUpdating = True
> >> >> .EnableEvents = True
> >> >> End With
> >> >> End Sub
> >> >>
> >> >> Function LastRow(sh As Worksheet)
> >> >> On Error Resume Next
> >> >> LastRow = sh.Cells.Find(What:="*", _
> >> >> After:=sh.Range("A1"), _
> >> >> Lookat:=xlPart, _
> >> >> LookIn:=xlFormulas, _
> >> >> SearchOrder:=xlByRows, _
> >> >> SearchDirection:=xlPrevious, _
> >> >> MatchCase:=False).Row
> >> >> On Error GoTo 0
> >> >> End Function
> >> >>
> >> >>
> >> >>
> >> >> "sam" <sam@discussions.microsoft.com> schreef in bericht
> >> >> news:93CE027D-3299-4321-83BE-E27C103BDDF4@microsoft.com...
> >> >> > Hey Ron, This worked out great. Thanks a Lot for your help.
> >> >> > One thing I also wanted was to mail column headers with the last
> >> >> > updated
> >> >> > row.. The first row contains column headers and I would like to mail
> >> >> > that
> >> >> > as
> >> >> > well.
> >> >> > I tried updaing this part of the code:
> >> >> >
> >> >> > Set Source = Range("A" & Lrow & ":K" &
> >> >> > Lrow).SpecialCells(xlCellTypeVisible)
> >> >> >
> >> >> > to:
> >> >> >
> >> >> > Set Source = Range("A" & Lrow & ":K" & Lrow &
> >> >> > Frow).SpecialCells(xlCellTypeVisible)
> >> >> >
> >> >> > But it didnt mail the first row, ALso when I it mails, it asks me to
> >> >> > allow
> >> >> > or deny the macro to mail the book, should I set
> >> >> > Application.DisplayAlerts =
> >> >> > False ?
> >> >> >
> >> >> > Thanks a lot again.
> >> >> >
> >> >> >
> >> >> > "Ron de Bruin" wrote:
> >> >> >
> >> >> >> Change the mail address to yours before you test it
> >> >> >>
> >> >> >>
> >> >> >> "Ron de Bruin" <rondebruin@kabelfoon.nl> schreef in bericht
> >> >> >> news:%23hQpB15DKHA.4064@TK2MSFTNGP04.phx.gbl...
> >> >> >> > Hi Sam
> >> >> >> >
> >> >> >> > Try this
> >> >> >> >
> >> >> >> > Sub Mail_Range()
> >> >> >> > 'Working in 2000-2007
> >> >> >> > Dim Source As Range
> >> >> >> > Dim Dest As Workbook
> >> >> >> > Dim wb As Workbook
> >> >> >> > Dim TempFilePath As String
> >> >> >> > Dim TempFileName As String
> >> >> >> > Dim FileExtStr As String
> >> >> >> > Dim FileFormatNum As Long
> >> >> >> > Dim Lrow As Long
> >> >> >> >
> >> >> >> > Lrow = LastRow(ActiveSheet)
> >> >> >> >
> >> >> >> > Set Source = Nothing
> >> >> >> > On Error Resume Next
> >> >> >> > Set Source = Range("A" & Lrow & ":K" &
> >> >> >> > Lrow).SpecialCells(xlCellTypeVisible)
> >> >> >> > On Error GoTo 0
> >> >> >> >
> >> >> >> > If Source Is Nothing Then
> >> >> >> > MsgBox "The source is not a range or the sheet is
> >> >> >> > protected,
> >> >> >> > " &
> >> >> >> > _
> >> >> >> > "please correct and try again.", vbOKOnly
> >> >> >> > Exit Sub
> >> >> >> > End If
> >> >> >> >
> >> >> >> > With Application
> >> >> >> > .ScreenUpdating = False
> >> >> >> > .EnableEvents = False
> >> >> >> > End With
> >> >> >> >
> >> >> >> > Set wb = ActiveWorkbook
> >> >> >> > Set Dest = Workbooks.Add(xlWBATWorksheet)
> >> >> >> >
> >> >> >> > Source.Copy
> >> >> >> > With Dest.Sheets(1)
> >> >> >> > .Cells(1).PasteSpecial Paste:=8
> >> >> >> > .Cells(1).PasteSpecial Paste:=xlPasteValues
> >> >> >> > .Cells(1).PasteSpecial Paste:=xlPasteFormats
> >> >> >> > .Cells(1).Select
> >> >> >> > Application.CutCopyMode = False
> >> >> >> > End With
> >> >> >> >
> >> >> >> > TempFilePath = Environ$("temp") & "\"
> >> >> >> > TempFileName = "Selection of " & wb.Name & " " _
> >> >> >> > & Format(Now, "dd-mmm-yy h-mm-ss")
> >> >> >> >
> >> >> >> > If Val(Application.Version) < 12 Then
> >> >> >> > 'You use Excel 2000-2003
> >> >> >> > FileExtStr = ".xls": FileFormatNum = -4143
> >> >> >> > Else
> >> >> >> > 'You use Excel 2007
> >> >> >> > FileExtStr = ".xlsx": FileFormatNum = 51
> >> >> >> > End If
> >> >> >> >
> >> >> >> > With Dest
> >> >> >> >
> >> >> >> > .SaveAs TempFilePath & TempFileName & FileExtStr, _
> >> >> >> > FileFormat:=FileFormatNum
> >> >> >> > On Error Resume Next
> >> >> >> > .SendMail "rondebruin@kabelfoon.nl", _
> >> >> >> > "This is the Subject line"
> >> >> >> > On Error GoTo 0
> >> >> >> > .Close SaveChanges:=False
> >> >> >> > End With
> >> >> >> >
> >> >> >> > Kill TempFilePath & TempFileName & FileExtStr
> >> >> >> >
> >> >> >> > With Application
> >> >> >> > .ScreenUpdating = True
> >> >> >> > .EnableEvents = True
> >> >> >> > End With
> >> >> >> > End Sub
> >> >> >> >
> >> >> >> > Function LastRow(sh As Worksheet)
> >> >> >> > On Error Resume Next
> >> >> >> > LastRow = sh.Cells.Find(What:="*", _
> >> >> >> > After:=sh.Range("A1"), _
> >> >> >> > Lookat:=xlPart, _
> >> >> >> > LookIn:=xlFormulas, _
> >> >> >> > SearchOrder:=xlByRows, _
> >> >> >> > SearchDirection:=xlPrevious, _
> >> >> >> > MatchCase:=False).Row
> >> >> >> > On Error GoTo 0
> >> >> >> > End Function
> >> >> >> >
> >> >> >> >
> >> >> >> >
> >> >> >> > "sam" <sam@discussions.microsoft.com> schreef in bericht
> >> >> >> > news:72EF3B4A-476D-4239-ACA9-1D273BD8B180@microsoft.com...
> >> >> >> >> Thanks for your reply Ron,
> >> >> >> >> I have 26 cells of data in a row that I need to mail, from A to
> >> >> >> >> Z,
> >> >> >> >> I
> >> >> >> >> have

Ron de Bruin

7/28/2009 8:45:00 PM

0

Why you open a workook ???
Set Dest = Workbooks.Open(Filename:="H:\Book11.xlsm")

The only thing that you must do is that your sheet with data is active
The code will create a new workbook for you save/mail/delete it


--

Regards Ron de Bruin
http://www.rondebruin.n...


"sam" <sam@discussions.microsoft.com> schreef in bericht
news:772CA344-146A-40B0-86B6-67BFB24E36F4@microsoft.com...
>I think I have messed up your code a litte.. will work on it from start,
> I am getting a "run time error, Object required" on this line:
>
> ------> Source1.Copy
> With Dest.Sheets(1)
> .Cells(1).PasteSpecial Paste:=8
> .Cells(1).PasteSpecial Paste:=xlPasteValues
> .Cells(1).PasteSpecial Paste:=xlPasteFormats
> .Cells(1).Select
> Application.CutCopyMode = False
> End With
>
>
> I have declared everything and also set my workbook, Here is the code:
>
> Dim Source1 As Range
> Dim Source2 As Range
> Dim Lrow As Long
> Dim TempFilePath As String
> Dim TempFileName As String
> Dim OutApp As Object
> Dim OutMail As Object
> Dim Dest As Workbook
>
> Lrow = LastRow(ActiveSheet)
>
> On Error Resume Next
> Set Source1 = Range("A1:W1")
> On Error GoTo 0
>
> On Error Resume Next
> Set Source2 = Range("A" & Lrow & ":W" & Lrow)
> On Error GoTo 0
>
> Set Dest = Workbooks.Open(Filename:="H:\Book11.xlsm")
>
> Am i missing something?
>
> Thanks in Advance
>
> "Ron de Bruin" wrote:
>
>> Hi Sam
>>
>> That it is doing now
>>
>> It create a new workbook
>> Copy the header and last row in it
>> Save it
>> Mail it
>> delete it
>>
>> Your workbook with the userform is still the same
>>
>>
>>
>>
>> --
>>
>> Regards Ron de Bruin
>> http://www.rondebruin.n...
>>
>>
>> "sam" <sam@discussions.microsoft.com> schreef in bericht
>> news:16AE6587-5A3E-4E52-8E73-A76A05BBBF31@microsoft.com...
>> > Hey Ron, Is this approach possible?
>> >
>> > 1. Saving all User inputs(accepted through userform) in a workbook
>> > template,
>> > lets say: UserWb.xls
>> > 2. Now, Saving a copy of the same workbook(UserWb.xls) as UserWbCpy.xls
>> > with
>> > just he current user entry.
>> > 3. Mailing the copy that includes current user entry
>> > only(UserWbCpy.xls)
>> > 4. Deleting the copy(UserWbCpy.xls).
>> >
>> > But the original template still remains(UserWb.xls) as I want to keep a
>> > backup file of all user inputs.
>> >
>> > Thanks in advance
>> >
>> >
>> > "Ron de Bruin" wrote:
>> >
>> >> You are welcome
>> >>
>> >>
>> >>
>> >> --
>> >>
>> >> Regards Ron de Bruin
>> >> http://www.rondebruin.n...
>> >>
>> >>
>> >> "sam" <sam@discussions.microsoft.com> schreef in bericht
>> >> news:1CD297FF-7E83-4E7B-870C-07249C032C72@microsoft.com...
>> >> > Thank you for all your help, it worked out great. I have to tweak
>> >> > the
>> >> > code
>> >> > a
>> >> > little to make it work my way, thank you for your sources available
>> >> > online.
>> >> >
>> >> > "Ron de Bruin" wrote:
>> >> >
>> >> >> Use this then and read this page about the warning
>> >> >> http://www.rondebruin.nl/mail/p...
>> >> >>
>> >> >> If you use Outlook you can also add body text if you want
>> >> >> See
>> >> >> http://www.rondebruin.nl/se...
>> >> >>
>> >> >>
>> >> >> Sub Mail_Range()
>> >> >> 'Working in 2000-2007
>> >> >> Dim Source1 As Range
>> >> >> Dim Source2 As Range
>> >> >> Dim Dest As Workbook
>> >> >> Dim wb As Workbook
>> >> >> Dim TempFilePath As String
>> >> >> Dim TempFileName As String
>> >> >> Dim FileExtStr As String
>> >> >> Dim FileFormatNum As Long
>> >> >> Dim Lrow As Long
>> >> >>
>> >> >> Lrow = LastRow(ActiveSheet)
>> >> >>
>> >> >> On Error Resume Next
>> >> >> Set Source1 = Range("A1:K1")
>> >> >> On Error GoTo 0
>> >> >>
>> >> >> On Error Resume Next
>> >> >> Set Source2 = Range("A" & Lrow & ":K" & Lrow)
>> >> >> On Error GoTo 0
>> >> >>
>> >> >>
>> >> >> With Application
>> >> >> .ScreenUpdating = False
>> >> >> .EnableEvents = False
>> >> >> End With
>> >> >>
>> >> >> Set wb = ActiveWorkbook
>> >> >> Set Dest = Workbooks.Add(xlWBATWorksheet)
>> >> >>
>> >> >> Source1.Copy
>> >> >> With Dest.Sheets(1)
>> >> >> .Cells(1).PasteSpecial Paste:=8
>> >> >> .Cells(1).PasteSpecial Paste:=xlPasteValues
>> >> >> .Cells(1).PasteSpecial Paste:=xlPasteFormats
>> >> >> .Cells(1).Select
>> >> >> Application.CutCopyMode = False
>> >> >> End With
>> >> >>
>> >> >> Source2.Copy
>> >> >> With Dest.Sheets(1)
>> >> >> .Cells(2, 1).PasteSpecial Paste:=8
>> >> >> .Cells(2, 1).PasteSpecial Paste:=xlPasteValues
>> >> >> .Cells(2, 1).PasteSpecial Paste:=xlPasteFormats
>> >> >> .Cells(2, 1).Select
>> >> >> Application.CutCopyMode = False
>> >> >> End With
>> >> >>
>> >> >> TempFilePath = Environ$("temp") & "\"
>> >> >> TempFileName = "Selection of " & wb.Name & " " _
>> >> >> & Format(Now, "dd-mmm-yy h-mm-ss")
>> >> >>
>> >> >> If Val(Application.Version) < 12 Then
>> >> >> 'You use Excel 2000-2003
>> >> >> FileExtStr = ".xls": FileFormatNum = -4143
>> >> >> Else
>> >> >> 'You use Excel 2007
>> >> >> FileExtStr = ".xlsx": FileFormatNum = 51
>> >> >> End If
>> >> >>
>> >> >> With Dest
>> >> >>
>> >> >> .SaveAs TempFilePath & TempFileName & FileExtStr, _
>> >> >> FileFormat:=FileFormatNum
>> >> >> On Error Resume Next
>> >> >> .SendMail "rondebruin@kabelfoon.nl", _
>> >> >> "This is the Subject line"
>> >> >> On Error GoTo 0
>> >> >> .Close SaveChanges:=False
>> >> >> End With
>> >> >>
>> >> >> Kill TempFilePath & TempFileName & FileExtStr
>> >> >>
>> >> >> With Application
>> >> >> .ScreenUpdating = True
>> >> >> .EnableEvents = True
>> >> >> End With
>> >> >> End Sub
>> >> >>
>> >> >> Function LastRow(sh As Worksheet)
>> >> >> On Error Resume Next
>> >> >> LastRow = sh.Cells.Find(What:="*", _
>> >> >> After:=sh.Range("A1"), _
>> >> >> Lookat:=xlPart, _
>> >> >> LookIn:=xlFormulas, _
>> >> >> SearchOrder:=xlByRows, _
>> >> >> SearchDirection:=xlPrevious, _
>> >> >> MatchCase:=False).Row
>> >> >> On Error GoTo 0
>> >> >> End Function
>> >> >>
>> >> >>
>> >> >>
>> >> >> "sam" <sam@discussions.microsoft.com> schreef in bericht
>> >> >> news:93CE027D-3299-4321-83BE-E27C103BDDF4@microsoft.com...
>> >> >> > Hey Ron, This worked out great. Thanks a Lot for your help.
>> >> >> > One thing I also wanted was to mail column headers with the last
>> >> >> > updated
>> >> >> > row.. The first row contains column headers and I would like to
>> >> >> > mail
>> >> >> > that
>> >> >> > as
>> >> >> > well.
>> >> >> > I tried updaing this part of the code:
>> >> >> >
>> >> >> > Set Source = Range("A" & Lrow & ":K" &
>> >> >> > Lrow).SpecialCells(xlCellTypeVisible)
>> >> >> >
>> >> >> > to:
>> >> >> >
>> >> >> > Set Source = Range("A" & Lrow & ":K" & Lrow &
>> >> >> > Frow).SpecialCells(xlCellTypeVisible)
>> >> >> >
>> >> >> > But it didnt mail the first row, ALso when I it mails, it asks me
>> >> >> > to
>> >> >> > allow
>> >> >> > or deny the macro to mail the book, should I set
>> >> >> > Application.DisplayAlerts =
>> >> >> > False ?
>> >> >> >
>> >> >> > Thanks a lot again.
>> >> >> >
>> >> >> >
>> >> >> > "Ron de Bruin" wrote:
>> >> >> >
>> >> >> >> Change the mail address to yours before you test it
>> >> >> >>
>> >> >> >>
>> >> >> >> "Ron de Bruin" <rondebruin@kabelfoon.nl> schreef in bericht
>> >> >> >> news:%23hQpB15DKHA.4064@TK2MSFTNGP04.phx.gbl...
>> >> >> >> > Hi Sam
>> >> >> >> >
>> >> >> >> > Try this
>> >> >> >> >
>> >> >> >> > Sub Mail_Range()
>> >> >> >> > 'Working in 2000-2007
>> >> >> >> > Dim Source As Range
>> >> >> >> > Dim Dest As Workbook
>> >> >> >> > Dim wb As Workbook
>> >> >> >> > Dim TempFilePath As String
>> >> >> >> > Dim TempFileName As String
>> >> >> >> > Dim FileExtStr As String
>> >> >> >> > Dim FileFormatNum As Long
>> >> >> >> > Dim Lrow As Long
>> >> >> >> >
>> >> >> >> > Lrow = LastRow(ActiveSheet)
>> >> >> >> >
>> >> >> >> > Set Source = Nothing
>> >> >> >> > On Error Resume Next
>> >> >> >> > Set Source = Range("A" & Lrow & ":K" &
>> >> >> >> > Lrow).SpecialCells(xlCellTypeVisible)
>> >> >> >> > On Error GoTo 0
>> >> >> >> >
>> >> >> >> > If Source Is Nothing Then
>> >> >> >> > MsgBox "The source is not a range or the sheet is
>> >> >> >> > protected,
>> >> >> >> > " &
>> >> >> >> > _
>> >> >> >> > "please correct and try again.", vbOKOnly
>> >> >> >> > Exit Sub
>> >> >> >> > End If
>> >> >> >> >
>> >> >> >> > With Application
>> >> >> >> > .ScreenUpdating = False
>> >> >> >> > .EnableEvents = False
>> >> >> >> > End With
>> >> >> >> >
>> >> >> >> > Set wb = ActiveWorkbook
>> >> >> >> > Set Dest = Workbooks.Add(xlWBATWorksheet)
>> >> >> >> >
>> >> >> >> > Source.Copy
>> >> >> >> > With Dest.Sheets(1)
>> >> >> >> > .Cells(1).PasteSpecial Paste:=8
>> >> >> >> > .Cells(1).PasteSpecial Paste:=xlPasteValues
>> >> >> >> > .Cells(1).PasteSpecial Paste:=xlPasteFormats
>> >> >> >> > .Cells(1).Select
>> >> >> >> > Application.CutCopyMode = False
>> >> >> >> > End With
>> >> >> >> >
>> >> >> >> > TempFilePath = Environ$("temp") & "\"
>> >> >> >> > TempFileName = "Selection of " & wb.Name & " " _
>> >> >> >> > & Format(Now, "dd-mmm-yy h-mm-ss")
>> >> >> >> >
>> >> >> >> > If Val(Application.Version) < 12 Then
>> >> >> >> > 'You use Excel 2000-2003
>> >> >> >> > FileExtStr = ".xls": FileFormatNum = -4143
>> >> >> >> > Else
>> >> >> >> > 'You use Excel 2007
>> >> >> >> > FileExtStr = ".xlsx": FileFormatNum = 51
>> >> >> >> > End If
>> >> >> >> >
>> >> >> >> > With Dest
>> >> >> >> >
>> >> >> >> > .SaveAs TempFilePath & TempFileName & FileExtStr, _
>> >> >> >> > FileFormat:=FileFormatNum
>> >> >> >> > On Error Resume Next
>> >> >> >> > .SendMail "rondebruin@kabelfoon.nl", _
>> >> >> >> > "This is the Subject line"
>> >> >> >> > On Error GoTo 0
>> >> >> >> > .Close SaveChanges:=False
>> >> >> >> > End With
>> >> >> >> >
>> >> >> >> > Kill TempFilePath & TempFileName & FileExtStr
>> >> >> >> >
>> >> >> >> > With Application
>> >> >> >> > .ScreenUpdating = True
>> >> >> >> > .EnableEvents = True
>> >> >> >> > End With
>> >> >> >> > End Sub
>> >> >> >> >
>> >> >> >> > Function LastRow(sh As Worksheet)
>> >> >> >> > On Error Resume Next
>> >> >> >> > LastRow = sh.Cells.Find(What:="*", _
>> >> >> >> > After:=sh.Range("A1"), _
>> >> >> >> > Lookat:=xlPart, _
>> >> >> >> > LookIn:=xlFormulas, _
>> >> >> >> > SearchOrder:=xlByRows, _
>> >> >> >> > SearchDirection:=xlPrevious, _
>> >> >> >> > MatchCase:=False).Row
>> >> >> >> > On Error GoTo 0
>> >> >> >> > End Function
>> >> >> >> >
>> >> >> >> >
>> >> >> >> >
>> >> >> >> > "sam" <sam@discussions.microsoft.com> schreef in bericht
>> >> >> >> > news:72EF3B4A-476D-4239-ACA9-1D273BD8B180@microsoft.com...
>> >> >> >> >> Thanks for your reply Ron,
>> >> >> >> >> I have 26 cells of data in a row that I need to mail, from A
>> >> >> >> >> to
>> >> >> >> >> Z,
>> >> >> >> >> I
>> >> >> >> >> have
>
> __________ Information from ESET Smart Security, version of virus
> signature database 4286 (20090728) __________
>
> The message was checked by ESET Smart Security.
>
> http://ww...
>
>
>


__________ Information from ESET Smart Security, version of virus signature database 4286 (20090728) __________

The message was checked by ESET Smart Security.

http://ww...