Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Make sheet change stick after Application.Inputbox

I'm not sure what you mean by sticking, but maybe...

Option Explicit
Sub testme()
Dim myRng As Range
Set myRng = Nothing
On Error Resume Next
Set myRng = Application.InputBox(Prompt:="pick a range", Type:=8)
On Error GoTo 0

If myRng Is Nothing Then
'do nothing
Else
Application.Goto myRng ', scroll:=true
End If

End Sub

Or maybe...

Application.Goto myRng.Parent.range("A1") ', scroll:=true



RB Smissaert wrote:

Is there a simple way to make a sheet change stick that was done while in
the Application.InputBox dialog (with Type:=8)?
I can do it by parsing out the sheet name from the resulting range and then
activate that sheet, but I have a feeling that there might be a simpler way
to do this.

RBS


--

Dave Peterson
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Make sheet change stick after Application.Inputbox

With sticking I mean that it doesn't return to the sheet that was active
when the Application.InputBox was started.

Thanks to both and Range.Parent is the simple answer indeed.

RBS


"Dave Peterson" wrote in message
...
I'm not sure what you mean by sticking, but maybe...

Option Explicit
Sub testme()
Dim myRng As Range
Set myRng = Nothing
On Error Resume Next
Set myRng = Application.InputBox(Prompt:="pick a range", Type:=8)
On Error GoTo 0

If myRng Is Nothing Then
'do nothing
Else
Application.Goto myRng ', scroll:=true
End If

End Sub

Or maybe...

Application.Goto myRng.Parent.range("A1") ', scroll:=true



RB Smissaert wrote:

Is there a simple way to make a sheet change stick that was done while in
the Application.InputBox dialog (with Type:=8)?
I can do it by parsing out the sheet name from the resulting range and
then
activate that sheet, but I have a feeling that there might be a simpler
way
to do this.

RBS


--

Dave Peterson


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Make sheet change stick after Application.Inputbox

For completeness might want to do

rng.Parent.Parent.Activate
rng.Parent.Activate

Just in case, there's a bug with Type:=8 on sheets with certain types of CF,
two workarounds here

http://www.jkp-ads.com/Articles/SelectARange.asp

Regards,
Peter T


"RB Smissaert" wrote in message
...
With sticking I mean that it doesn't return to the sheet that was active
when the Application.InputBox was started.

Thanks to both and Range.Parent is the simple answer indeed.

RBS


"Dave Peterson" wrote in message
...
I'm not sure what you mean by sticking, but maybe...

Option Explicit
Sub testme()
Dim myRng As Range
Set myRng = Nothing
On Error Resume Next
Set myRng = Application.InputBox(Prompt:="pick a range", Type:=8)
On Error GoTo 0

If myRng Is Nothing Then
'do nothing
Else
Application.Goto myRng ', scroll:=true
End If

End Sub

Or maybe...

Application.Goto myRng.Parent.range("A1") ', scroll:=true



RB Smissaert wrote:

Is there a simple way to make a sheet change stick that was done while
in
the Application.InputBox dialog (with Type:=8)?
I can do it by parsing out the sheet name from the resulting range and
then
activate that sheet, but I have a feeling that there might be a simpler
way
to do this.

RBS


--

Dave Peterson




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Make sheet change stick after Application.Inputbox

Thanks for that, chance is very small my users will come across that bug,
but you never know.
Didn't know you could use Type:=0 argument and still pick the range up.
I will go for the second work-around then.
I used something similar (parsing out the sheet from the range address)
before
I knew about rng.Parent:

Function GetSheetFromRange(rng As Range) As Worksheet

Dim lPos1 As Long
Dim lPos2 As Long
Dim strAddress As String
Dim strSheet As String

strAddress = rng.Address(, , , True)
lPos1 = InStr(1, strAddress, "]")
lPos2 = InStr(1, strAddress, "!")
strSheet = Mid$(strAddress, lPos1 + 1, (lPos2 - lPos1) - 1)

'not sure why the single quote is there sometimes and sometimes not
'------------------------------------------------------------------
If Right$(strSheet, 1) = Chr(39) Then
strSheet = Left$(strSheet, Len(strSheet) - 1)
End If

Set GetSheetFromRange = Sheets(strSheet)

End Function


RBS



"Peter T" <peter_t@discussions wrote in message
...
For completeness might want to do

rng.Parent.Parent.Activate
rng.Parent.Activate

Just in case, there's a bug with Type:=8 on sheets with certain types of
CF, two workarounds here

http://www.jkp-ads.com/Articles/SelectARange.asp

Regards,
Peter T


"RB Smissaert" wrote in message
...
With sticking I mean that it doesn't return to the sheet that was active
when the Application.InputBox was started.

Thanks to both and Range.Parent is the simple answer indeed.

RBS


"Dave Peterson" wrote in message
...
I'm not sure what you mean by sticking, but maybe...

Option Explicit
Sub testme()
Dim myRng As Range
Set myRng = Nothing
On Error Resume Next
Set myRng = Application.InputBox(Prompt:="pick a range", Type:=8)
On Error GoTo 0

If myRng Is Nothing Then
'do nothing
Else
Application.Goto myRng ', scroll:=true
End If

End Sub

Or maybe...

Application.Goto myRng.Parent.range("A1") ', scroll:=true



RB Smissaert wrote:

Is there a simple way to make a sheet change stick that was done while
in
the Application.InputBox dialog (with Type:=8)?
I can do it by parsing out the sheet name from the resulting range and
then
activate that sheet, but I have a feeling that there might be a simpler
way
to do this.

RBS

--

Dave Peterson





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Make sheet change stick after Application.Inputbox

That's one of the nice things about using application.goto.

It doesn't need to activate a workbook, then the worksheet.

Peter T wrote:

For completeness might want to do

rng.Parent.Parent.Activate
rng.Parent.Activate

Just in case, there's a bug with Type:=8 on sheets with certain types of CF,
two workarounds here

http://www.jkp-ads.com/Articles/SelectARange.asp

Regards,
Peter T

"RB Smissaert" wrote in message
...
With sticking I mean that it doesn't return to the sheet that was active
when the Application.InputBox was started.

Thanks to both and Range.Parent is the simple answer indeed.

RBS


"Dave Peterson" wrote in message
...
I'm not sure what you mean by sticking, but maybe...

Option Explicit
Sub testme()
Dim myRng As Range
Set myRng = Nothing
On Error Resume Next
Set myRng = Application.InputBox(Prompt:="pick a range", Type:=8)
On Error GoTo 0

If myRng Is Nothing Then
'do nothing
Else
Application.Goto myRng ', scroll:=true
End If

End Sub

Or maybe...

Application.Goto myRng.Parent.range("A1") ', scroll:=true



RB Smissaert wrote:

Is there a simple way to make a sheet change stick that was done while
in
the Application.InputBox dialog (with Type:=8)?
I can do it by parsing out the sheet name from the resulting range and
then
activate that sheet, but I have a feeling that there might be a simpler
way
to do this.

RBS

--

Dave Peterson



--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Make sheet change stick after Application.Inputbox

"Dave Peterson" wrote in message

That's one of the nice things about using application.goto.

It doesn't need to activate a workbook, then the worksheet.


Yes that's easier.

Regards,
Peter T


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Make sheet change stick after Application.Inputbox

I like that function GetInputRange, nice work, and will use that now.
Maybe Application.Goto could be a little refinement as is this for if you
don't want
the selection to be the default input:

If Len(sDefault) = 0 Or sDefault = "nil" Then
If TypeName(Application.Selection) = "Range" And sDefault < "nil" Then
sDefault = "=" & Application.Selection.Address
'InputBox cannot handle address/formulas over 255
If Len(sDefault) 240 Then
sDefault = "=" & Application.ActiveCell.Address
End If
Else
If TypeName(Application.ActiveSheet) = "Chart" Then
sDefault = " first select a Worksheet"
Else
sDefault = " Select Cell(s) or type address"
End If
End If
End If


RBS


"Peter T" <peter_t@discussions wrote in message
...
For completeness might want to do

rng.Parent.Parent.Activate
rng.Parent.Activate

Just in case, there's a bug with Type:=8 on sheets with certain types of
CF, two workarounds here

http://www.jkp-ads.com/Articles/SelectARange.asp

Regards,
Peter T


"RB Smissaert" wrote in message
...
With sticking I mean that it doesn't return to the sheet that was active
when the Application.InputBox was started.

Thanks to both and Range.Parent is the simple answer indeed.

RBS


"Dave Peterson" wrote in message
...
I'm not sure what you mean by sticking, but maybe...

Option Explicit
Sub testme()
Dim myRng As Range
Set myRng = Nothing
On Error Resume Next
Set myRng = Application.InputBox(Prompt:="pick a range", Type:=8)
On Error GoTo 0

If myRng Is Nothing Then
'do nothing
Else
Application.Goto myRng ', scroll:=true
End If

End Sub

Or maybe...

Application.Goto myRng.Parent.range("A1") ', scroll:=true



RB Smissaert wrote:

Is there a simple way to make a sheet change stick that was done while
in
the Application.InputBox dialog (with Type:=8)?
I can do it by parsing out the sheet name from the resulting range and
then
activate that sheet, but I have a feeling that there might be a simpler
way
to do this.

RBS

--

Dave Peterson





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Make pivotchart formatting stick after pivottable refresh. larry garka Charts and Charting in Excel 3 June 5th 08 03:12 PM
application.inputbox Christmas May[_2_] Excel Programming 5 November 22nd 06 04:11 PM
Where to stick macro to change default comment font? [email protected] Excel Discussion (Misc queries) 1 January 1st 05 12:57 AM
(Today) function can you make it stick B. E. Smith Excel Programming 3 November 30th 04 09:51 AM
Inputbox and Application.InputBox Maria[_7_] Excel Programming 1 September 20th 04 11:36 AM


All times are GMT +1. The time now is 10:44 AM.

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"