LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Value of the "Last Cell"

This is what I want to do;
I have this spreadsheet that is going to be used for updating data on
an Outlook Form.
When the spreadsheet opens the user clicks a button that will import
the Outlook Items from the public folder into the spreadsheet. This
will also bring in the EntryID for each Item. Now the user can edit
these items.

Ex… Lets say I am in Cell B2 and I type in "Tony", when I leave Cell
B2 and go to B3 my code will execute and take the value of Cell B10
(which happens to be my entryID) and the value of B2 ("Tony") and put
it in the First Name field on the Outlook Form that matches that
entryID and storeID.

Here are the issues I am experencing now:
1. I am not sure how to reference the previous cell that was edited.
I have tried using SpecialCells(xlCellTypeLastCell) but this doesn't
seen to work when you click the delete key while your on a cell.
2. I also need to reference the last cell that is on the same row as
the previouse cell. This is pretty much the same problem as #1 but I
thought it was worth mentioning.
3. I am unsure of where the best place to collect this data
a. Worksheet_Change()
b. Worksheet_SelectionChange()
c. Workbook_SheetSelectionChange()

Any suggestions or help would be greatly appreciated.

‘This is the code I have so far:

Private Sub Worksheet_Change(ByVal Target As Range)

Set myOlApp = CreateObject("Outlook.Application")
Set MyNameSpace = myOlApp.GetNamespace("MAPI")
Set PublicFolders = MyNameSpace.Folders("Public Folders")
Set AllPublicFolders = PublicFolders.Folders("All Public Folders")
Set Folders1 = AllPublicFolders.Folders("Public Folder 1")
Set XFld = Folders1.Folders("XFld")
Set Items = Fld.Items

Dim xCol As Variant
Dim storeID As String
Dim entryID As String
Dim LeftCell As Range
Dim RightCell As Range

‘HERE I AM USING SpecialCells(xlCellTypeLastCell) TO GET THE LAST
CELL
‘AND End(xlToRight) TO GET THE GET THE LAST CELL ON THAT ROW WHICH
HOLDS THE entryID
x = ActiveCell.SpecialCells(xlCellTypeLastCell).End(xl ToRight)

entryID = X
storeID = XRef.storeID

Set XRefItem = MyNameSpace.GetItemFromID(entryID, storeID)

‘A TEST TO SEE IF I AM GETTING RIGHT RECORD
MsgBox XRefItem.UserProperties("StockNum")

‘This is where it puts it in the form
xCol = Target.Column

If xCol = 1 Then
'xRef.UserProperties("Field1") = Target
Else
If xCol = 2 Then
'xRef.UserProperties("Field2") = Target
Else
If xCol = 3 Then
'xRef.UserProperties("Field3") = Target
Else
End If
End If
End If


Set XRefItem = Nothing
Set Items = Nothing
Set XRef = Nothing
Set ddFolders = Nothing
Set AllPublicFolders = Nothing
Set PublicFolders = Nothing
Set MyNameSpace = Nothing
Set myOlApp = Nothing

End Sub
 
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
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
"CELL("FILENAME") NOT UPDATE AFTER "SAVE AS" ACTION yossie6 Excel Discussion (Misc queries) 1 June 16th 08 12:16 PM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
Help!!! Enter "7" in a cell and Excel changes the "7" to "11" immediately!!! [email protected] Excel Discussion (Misc queries) 3 January 5th 07 02:18 PM
Complex if test program possible? If "value" "value", paste "value" in another cell? jseabold Excel Discussion (Misc queries) 1 January 30th 06 10:01 PM


All times are GMT +1. The time now is 09:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"