PC Review


Reply
Thread Tools Rate Thread

How to activate a worksheet when a macro is running in the sheet m

 
 
=?Utf-8?B?QkZTV0U=?=
Guest
Posts: n/a
 
      18th Oct 2006
Problem:
I want to move to cell A1 (sheet 1) when a certain nr occurs in cell B1, for
ex 1. Cell B1 contains a formula that refers to a cell in sheet 2. My problem
is that this doesn´t happen until I do anything in sheet 1 like use one arrow
or klick with the mouse in a cell.

How can I activate sheet 1 within the macro below?

The macro looks like this:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Select Case Range("B1")
Case Is = 1 "The macro feel nr 1 but do not execute
until anything
Range("A1").Select happens in sheet 1"
End Select

Hope for a swift answer
BFSWE
End Sub

 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      18th Oct 2006

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Target.Address = "$B$1" Then
If Target.Value = 1 Then
Worksheets("Sheet1").Activate
Range("A1").Select
End If
End If
End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"BFSWE" <(E-Mail Removed)> wrote in message
news:F7DD8E4C-AE47-4BFB-A5E4-(E-Mail Removed)...
> Problem:
> I want to move to cell A1 (sheet 1) when a certain nr occurs in cell B1,

for
> ex 1. Cell B1 contains a formula that refers to a cell in sheet 2. My

problem
> is that this doesn´t happen until I do anything in sheet 1 like use one

arrow
> or klick with the mouse in a cell.
>
> How can I activate sheet 1 within the macro below?
>
> The macro looks like this:
> Private Sub Worksheet_SelectionChange(ByVal Target As Range)
>
> Select Case Range("B1")
> Case Is = 1 "The macro feel nr 1 but do not

execute
> until anything
> Range("A1").Select happens in sheet 1"
> End Select
>
> Hope for a swift answer
> BFSWE
> End Sub
>



 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      18th Oct 2006
A slight typo:

Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Target.Address = "$B$1" Then
If Target.Value = 1 Then
With Worksheets("Sheet1")
.Activate
.Range("A1").Select
End With
End If
End If
End Sub



Bob Phillips wrote:
>
> Private Sub Worksheet_SelectionChange(ByVal Target As Range)
>
> If Target.Address = "$B$1" Then
> If Target.Value = 1 Then
> Worksheets("Sheet1").Activate
> Range("A1").Select
> End If
> End If
> End Sub
>
> --
> HTH
>
> Bob Phillips
>
> (replace somewhere in email address with gmail if mailing direct)
>
> "BFSWE" <(E-Mail Removed)> wrote in message
> news:F7DD8E4C-AE47-4BFB-A5E4-(E-Mail Removed)...
> > Problem:
> > I want to move to cell A1 (sheet 1) when a certain nr occurs in cell B1,

> for
> > ex 1. Cell B1 contains a formula that refers to a cell in sheet 2. My

> problem
> > is that this doesn´t happen until I do anything in sheet 1 like use one

> arrow
> > or klick with the mouse in a cell.
> >
> > How can I activate sheet 1 within the macro below?
> >
> > The macro looks like this:
> > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> >
> > Select Case Range("B1")
> > Case Is = 1 "The macro feel nr 1 but do not

> execute
> > until anything
> > Range("A1").Select happens in sheet 1"
> > End Select
> >
> > Hope for a swift answer
> > BFSWE
> > End Sub
> >


--

Dave Peterson
 
Reply With Quote
 
=?Utf-8?B?QkZTV0U=?=
Guest
Posts: n/a
 
      19th Oct 2006
Hi Dave.

It still doesn´t work. Maybe the problem is how my Excel is configurated?
Maybe you can help med by doing a little experiment. If you have 2 sheets in
a workbook. In sheet1, cell B1, put a formula that fetch a nr from sheet2,
cell B1. Put your macro in the sheet1 module. Now, go to sheet2 and write 1
in cell B1. Go to sheet1 and se if excel has gone to cell A1. In my case this
doesn´t happen until I go to cell B1. I want this to happen directly without
having to do anything in the worksheet.

I hope you can help me with this problem.

Regards Bo

"Dave Peterson" skrev:

> A slight typo:
>
> Option Explicit
> Private Sub Worksheet_SelectionChange(ByVal Target As Range)
>
> If Target.Address = "$B$1" Then
> If Target.Value = 1 Then
> With Worksheets("Sheet1")
> .Activate
> .Range("A1").Select
> End With
> End If
> End If
> End Sub
>
>
>
> Bob Phillips wrote:
> >
> > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> >
> > If Target.Address = "$B$1" Then
> > If Target.Value = 1 Then
> > Worksheets("Sheet1").Activate
> > Range("A1").Select
> > End If
> > End If
> > End Sub
> >
> > --
> > HTH
> >
> > Bob Phillips
> >
> > (replace somewhere in email address with gmail if mailing direct)
> >
> > "BFSWE" <(E-Mail Removed)> wrote in message
> > news:F7DD8E4C-AE47-4BFB-A5E4-(E-Mail Removed)...
> > > Problem:
> > > I want to move to cell A1 (sheet 1) when a certain nr occurs in cell B1,

> > for
> > > ex 1. Cell B1 contains a formula that refers to a cell in sheet 2. My

> > problem
> > > is that this doesn´t happen until I do anything in sheet 1 like use one

> > arrow
> > > or klick with the mouse in a cell.
> > >
> > > How can I activate sheet 1 within the macro below?
> > >
> > > The macro looks like this:
> > > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> > >
> > > Select Case Range("B1")
> > > Case Is = 1 "The macro feel nr 1 but do not

> > execute
> > > until anything
> > > Range("A1").Select happens in sheet 1"
> > > End Select
> > >
> > > Hope for a swift answer
> > > BFSWE
> > > End Sub
> > >

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
=?Utf-8?B?QkZTV0U=?=
Guest
Posts: n/a
 
      19th Oct 2006
Hi Bob.

It still doesn´t work. Maybe the problem is how my Excel is configurated?
Maybe you can help med by doing a little experiment. If you have 2 sheets in
a workbook. In sheet1, cell B1, put a formula that fetch a nr from sheet2,
cell B1. Put your macro in the sheet1 module. Now, go to sheet2 and write 1
in cell B1. Go to sheet1 and se if excel has gone to cell A1. In my case this
doesn´t happen until I go to cell B1. I want this to happen directly without
having to do anything in the worksheet.

I hope you can help me with this problem.

Regards Bo

"Bob Phillips" skrev:

>
> Private Sub Worksheet_SelectionChange(ByVal Target As Range)
>
> If Target.Address = "$B$1" Then
> If Target.Value = 1 Then
> Worksheets("Sheet1").Activate
> Range("A1").Select
> End If
> End If
> End Sub
>
>
> --
> HTH
>
> Bob Phillips
>
> (replace somewhere in email address with gmail if mailing direct)
>
> "BFSWE" <(E-Mail Removed)> wrote in message
> news:F7DD8E4C-AE47-4BFB-A5E4-(E-Mail Removed)...
> > Problem:
> > I want to move to cell A1 (sheet 1) when a certain nr occurs in cell B1,

> for
> > ex 1. Cell B1 contains a formula that refers to a cell in sheet 2. My

> problem
> > is that this doesn´t happen until I do anything in sheet 1 like use one

> arrow
> > or klick with the mouse in a cell.
> >
> > How can I activate sheet 1 within the macro below?
> >
> > The macro looks like this:
> > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> >
> > Select Case Range("B1")
> > Case Is = 1 "The macro feel nr 1 but do not

> execute
> > until anything
> > Range("A1").Select happens in sheet 1"
> > End Select
> >
> > Hope for a swift answer
> > BFSWE
> > End Sub
> >

>
>
>

 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      19th Oct 2006
That is different. For one thing, you are now trying it with a referenced
cell, and another is that you are trying to do it with a Change, whereas
your original code showed SelectionChange. If you aren't selecting, you
cannot react to it.

What exactly are you trying to do, and why?

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"BFSWE" <(E-Mail Removed)> wrote in message
news:69C7CD73-4AC5-4FD2-A525-(E-Mail Removed)...
> Hi Bob.
>
> It still doesn´t work. Maybe the problem is how my Excel is configurated?
> Maybe you can help med by doing a little experiment. If you have 2 sheets

in
> a workbook. In sheet1, cell B1, put a formula that fetch a nr from sheet2,
> cell B1. Put your macro in the sheet1 module. Now, go to sheet2 and write

1
> in cell B1. Go to sheet1 and se if excel has gone to cell A1. In my case

this
> doesn´t happen until I go to cell B1. I want this to happen directly

without
> having to do anything in the worksheet.
>
> I hope you can help me with this problem.
>
> Regards Bo
>
> "Bob Phillips" skrev:
>
> >
> > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> >
> > If Target.Address = "$B$1" Then
> > If Target.Value = 1 Then
> > Worksheets("Sheet1").Activate
> > Range("A1").Select
> > End If
> > End If
> > End Sub
> >
> >
> > --
> > HTH
> >
> > Bob Phillips
> >
> > (replace somewhere in email address with gmail if mailing direct)
> >
> > "BFSWE" <(E-Mail Removed)> wrote in message
> > news:F7DD8E4C-AE47-4BFB-A5E4-(E-Mail Removed)...
> > > Problem:
> > > I want to move to cell A1 (sheet 1) when a certain nr occurs in cell

B1,
> > for
> > > ex 1. Cell B1 contains a formula that refers to a cell in sheet 2. My

> > problem
> > > is that this doesn´t happen until I do anything in sheet 1 like use

one
> > arrow
> > > or klick with the mouse in a cell.
> > >
> > > How can I activate sheet 1 within the macro below?
> > >
> > > The macro looks like this:
> > > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> > >
> > > Select Case Range("B1")
> > > Case Is = 1 "The macro feel nr 1 but do not

> > execute
> > > until anything
> > > Range("A1").Select happens in sheet 1"
> > > End Select
> > >
> > > Hope for a swift answer
> > > BFSWE
> > > End Sub
> > >

> >
> >
> >



 
Reply With Quote
 
=?Utf-8?B?QkZTV0U=?=
Guest
Posts: n/a
 
      19th Oct 2006
Hi Bob.

Thanks for your answer.

In a sheet I have a clock that is counting down to zero. I want to start a
macro when the clock has reached zero. I have a macro that does this but the
problem is that I have to do something, in the sheet, for this macro to work.
In the example below I have to go to cell B1 to activate the macro even if
I´m already standing on the cell when I´m putting 1 in cell B1 in sheet2. I
hope you understand my problem.

Regards Bo

"Bob Phillips" wrote:

> That is different. For one thing, you are now trying it with a referenced
> cell, and another is that you are trying to do it with a Change, whereas
> your original code showed SelectionChange. If you aren't selecting, you
> cannot react to it.
>
> What exactly are you trying to do, and why?
>
> --
> HTH
>
> Bob Phillips
>
> (replace somewhere in email address with gmail if mailing direct)
>
> "BFSWE" <(E-Mail Removed)> wrote in message
> news:69C7CD73-4AC5-4FD2-A525-(E-Mail Removed)...
> > Hi Bob.
> >
> > It still doesn´t work. Maybe the problem is how my Excel is configurated?
> > Maybe you can help med by doing a little experiment. If you have 2 sheets

> in
> > a workbook. In sheet1, cell B1, put a formula that fetch a nr from sheet2,
> > cell B1. Put your macro in the sheet1 module. Now, go to sheet2 and write

> 1
> > in cell B1. Go to sheet1 and se if excel has gone to cell A1. In my case

> this
> > doesn´t happen until I go to cell B1. I want this to happen directly

> without
> > having to do anything in the worksheet.
> >
> > I hope you can help me with this problem.
> >
> > Regards Bo
> >
> > "Bob Phillips" skrev:
> >
> > >
> > > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> > >
> > > If Target.Address = "$B$1" Then
> > > If Target.Value = 1 Then
> > > Worksheets("Sheet1").Activate
> > > Range("A1").Select
> > > End If
> > > End If
> > > End Sub
> > >
> > >
> > > --
> > > HTH
> > >
> > > Bob Phillips
> > >
> > > (replace somewhere in email address with gmail if mailing direct)
> > >
> > > "BFSWE" <(E-Mail Removed)> wrote in message
> > > news:F7DD8E4C-AE47-4BFB-A5E4-(E-Mail Removed)...
> > > > Problem:
> > > > I want to move to cell A1 (sheet 1) when a certain nr occurs in cell

> B1,
> > > for
> > > > ex 1. Cell B1 contains a formula that refers to a cell in sheet 2. My
> > > problem
> > > > is that this doesn´t happen until I do anything in sheet 1 like use

> one
> > > arrow
> > > > or klick with the mouse in a cell.
> > > >
> > > > How can I activate sheet 1 within the macro below?
> > > >
> > > > The macro looks like this:
> > > > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> > > >
> > > > Select Case Range("B1")
> > > > Case Is = 1 "The macro feel nr 1 but do not
> > > execute
> > > > until anything
> > > > Range("A1").Select happens in sheet 1"
> > > > End Select
> > > >
> > > > Hope for a swift answer
> > > > BFSWE
> > > > End Sub
> > > >
> > >
> > >
> > >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Worksheet- activate macro =?Utf-8?B?c2FyYWg=?= Microsoft Excel Misc 3 21st Mar 2007 04:44 PM
Worksheet Activate event if only one sheet in book KD Trader Microsoft Excel Programming 3 14th Mar 2007 03:20 PM
Prevent code in "Sheet Activate" from running when sheet made visible from other macr Simon Lloyd Microsoft Excel Programming 10 21st Jun 2006 09:15 AM
Return to Current Sheet in On (sheet activate) event macro =?Utf-8?B?UGF1bCBNb2xlcw==?= Microsoft Excel Programming 1 27th Mar 2005 03:16 PM
Run Macro on Worksheet Activate Matthew John Antoszkiw Microsoft Excel Programming 2 23rd Feb 2004 12:01 PM


Features
 

Advertising
 

Newsgroups
 


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