Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Remember Last Cell

Hi,

I need to remember the last destination selected in an inputbox as the
default input until next time a macro is run.

I started out with declaring a public variable to keep the address

Public LastDestination As Object

Then I used this variable as default input in the list box

If LastDestination Is Nothing Then
Set DestinationCell = Application.InputBox( _
prompt:="Select Destination", Type:=8)
Else
Set DestinationCell = Application.InputBox( _
prompt:="Select Destination", Type:=8,
Default:=LastDestination.Address)

End If

Set LastDestination = DestinationCell

Challenge: I only get a "local" address, e.g. "B5", and not the full address
with filename and sheetname included, e.g. [Book1]Sheet1!$C$5.

Any hints?

ExcelSwede


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 246
Default Remember Last Cell

On 18 Feb, 12:38, "ExcelSwede" wrote:
Hi,

I need to remember the last destination selected in an inputbox as the
default input until next time a macro is run.

I started out with declaring a public variable to keep the address

* * Public LastDestination As Object

Then I used this variable as default input in the list box

* * If LastDestination Is Nothing Then
* * * * Set DestinationCell = Application.InputBox( _
* * * * * * prompt:="Select Destination", Type:=8)
* * Else
* * * * Set DestinationCell = Application.InputBox( _
* * * * * * prompt:="Select Destination", Type:=8,
Default:=LastDestination.Address)

* * End If

* * Set LastDestination = DestinationCell

Challenge: I only get a "local" address, e.g. "B5", and not the full address
with filename and sheetname included, e.g. [Book1]Sheet1!$C$5.

Any hints?

ExcelSwede


can you just change the last line of code to the following?
Set LastDestination = "[" & thisworkbook.name & "]" & activesheet.name
& "!" & DestinationCell

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Remember Last Cell


MsgBox LastDestination.Address(external:=True)
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"ExcelSwede"

wrote in message
Hi,
I need to remember the last destination selected in an inputbox as the
default input until next time a macro is run.
I started out with declaring a public variable to keep the address
Public LastDestination As Object
Then I used this variable as default input in the list box

If LastDestination Is Nothing Then
Set DestinationCell = Application.InputBox( _
prompt:="Select Destination", Type:=8)
Else
Set DestinationCell = Application.InputBox( _
prompt:="Select Destination", Type:=8, Default:=LastDestination.Address)
End If

Set LastDestination = DestinationCell

Challenge: I only get a "local" address, e.g. "B5", and not the full address
with filename and sheetname included, e.g. [Book1]Sheet1!$C$5.
Any hints?
ExcelSwede


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Remember Last Cell

hi
here is something for you to think about. it drops the active file name,
active sheet name and input box input into cell a1. not what you want but
maybe it will give you ideas.
Dim fn As String
Dim sh As String
Dim ca As String
fn = ActiveWorkbook.Name
sh = ActiveSheet.Name
ca = InputBox("select destination")
Range("A1").Value = fn & ":" & sh & ":" & ca

regards
FSt1

"ExcelSwede" wrote:

Hi,

I need to remember the last destination selected in an inputbox as the
default input until next time a macro is run.

I started out with declaring a public variable to keep the address

Public LastDestination As Object

Then I used this variable as default input in the list box

If LastDestination Is Nothing Then
Set DestinationCell = Application.InputBox( _
prompt:="Select Destination", Type:=8)
Else
Set DestinationCell = Application.InputBox( _
prompt:="Select Destination", Type:=8,
Default:=LastDestination.Address)

End If

Set LastDestination = DestinationCell

Challenge: I only get a "local" address, e.g. "B5", and not the full address
with filename and sheetname included, e.g. [Book1]Sheet1!$C$5.

Any hints?

ExcelSwede



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Remember Last Cell

Brilliant solution! Many thanks!

/Chris

"Jim Cone" wrote in message
...

MsgBox LastDestination.Address(external:=True)
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"ExcelSwede"

wrote in message
Hi,
I need to remember the last destination selected in an inputbox as the
default input until next time a macro is run.
I started out with declaring a public variable to keep the address
Public LastDestination As Object
Then I used this variable as default input in the list box

If LastDestination Is Nothing Then
Set DestinationCell = Application.InputBox( _
prompt:="Select Destination", Type:=8)
Else
Set DestinationCell = Application.InputBox( _
prompt:="Select Destination", Type:=8,
Default:=LastDestination.Address)
End If

Set LastDestination = DestinationCell

Challenge: I only get a "local" address, e.g. "B5", and not the full
address
with filename and sheetname included, e.g. [Book1]Sheet1!$C$5.
Any hints?
ExcelSwede




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
Can a cell remember a number?... Markv Excel Discussion (Misc queries) 4 June 23rd 08 10:49 AM
Why and How Does Excel Remember The Last Cell? Jim J. Excel Worksheet Functions 2 April 30th 07 10:50 PM
Active Cell - Remember Paul Brown[_2_] Excel Programming 5 December 30th 05 04:19 PM
How do I get a cell to remember the last entry and add to it? jab Excel Discussion (Misc queries) 7 March 4th 05 05:30 PM
Remember a cell scrabtree[_2_] Excel Programming 2 September 16th 04 10:08 PM


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