In Sheet1
------------
Let's take A1 to be the cell
dependent on a random number
Put in A1: =1+RAND()
Sub TextFromOLmsg()
Const olFolderInbox = 6
Const olTxt = 0
Const ForReading = 1
Dim R As Integer
' Determine row of first available cell in "A:A"
R = Range("A65536").End(xlUp).Row + 1
Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objFolder = objNamespace.GetDefaultFolder(olFolderInbox)
Set colMailItems = objFolder.Items
Set FSO = CreateObject("Scripting.FileSystemObject")
strFileName = FSO.GetSpecialFolder(2) & "\TempMsg.txt"
Set objItem = colMailItems.GetLast()
objItem.SaveAs strFileName, olTxt
Set objFile = FSO.OpenTextFile(strFileName, ForReading)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
Cells(R, 1).Value = strLine
R = R + 1
Loop
objFile.Close
FSO.DeleteFile strFileName
Set objFolder = Nothing
Set objNamespace = Nothing
Set objOutlook = Nothing
Set FSO = Nothing
In Sheet2
-------------
Put in B1: =Sheet1!A1
List/fill sequentially in A2:A51, the numbers 1,2,3... 50
Select A1:B51
Click Data Table
Leave the "row input cell:" box empty
Put in the "column input cell:" box: C1
(C1 is arbitrary, it can any cell outside the range A1:B51)
Click OK
B2:B51 will be filled with 50* iterations of
the random formula result of Sheet1's A1
*disregarding the result in B1 itself
Each press of the F9 key will regenerate
another 50 iterations in B2:B51
Now you could just freeze the randomized values
in the range B2:B51
via a copy paste special values in-situ or elsewhere
--
"linkswanted" wrote:
Moving Companies http://www.losangelesmovingservices.blogspot.com/