Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default VBA .activate

Hi,

I am needing some help with a code, I have 150 sheets in a workbook in
relation to stock items, I have 4 columns of date I need to enter into these
sheets. e.g.

Date Stock +/- Stock Total Initials

These are the 4 headings of the columns, what I am looking to do is that I
fill in Date and Stock +/- after that I want to put in initials of person
removing stock e.g KJ then after I have input the initials and hit enter I
want to activate so that after initials are input it will automatically
return to sheet1 "Index of Stock"

Can anyone help me on this code?

Many thanks

Terilad
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default VBA .activate

Put the following event macro in the worksheet code area:

Private Sub Worksheet_Change(ByVal Target As Range)
Set t = Target
Set d = Range("D:D")
If Intersect(t, d) Is Nothing Then Exit Sub
If t.Value = "" Then Exit Sub
Sheets(1).Activate
End Sub
--
Gary''s Student - gsnu200835


"terilad" wrote:

Hi,

I am needing some help with a code, I have 150 sheets in a workbook in
relation to stock items, I have 4 columns of date I need to enter into these
sheets. e.g.

Date Stock +/- Stock Total Initials

These are the 4 headings of the columns, what I am looking to do is that I
fill in Date and Stock +/- after that I want to put in initials of person
removing stock e.g KJ then after I have input the initials and hit enter I
want to activate so that after initials are input it will automatically
return to sheet1 "Index of Stock"

Can anyone help me on this code?

Many thanks

Terilad

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default VBA .activate

Many thanks Gary''s Student, works a treat, I am a bit confused as I notice
the Index of Stock sheet is actually named as Sheet4 in VBA but this code
works with Sheets (1).activate How is this???

Also I have another 2 Private Sub Worksheet commands on these worksheets, do
these have to be integrated together or are they ok separate as 3 different
commands?

Many thanks

Terilad

"Gary''s Student" wrote:

Put the following event macro in the worksheet code area:

Private Sub Worksheet_Change(ByVal Target As Range)
Set t = Target
Set d = Range("D:D")
If Intersect(t, d) Is Nothing Then Exit Sub
If t.Value = "" Then Exit Sub
Sheets(1).Activate
End Sub
--
Gary''s Student - gsnu200835


"terilad" wrote:

Hi,

I am needing some help with a code, I have 150 sheets in a workbook in
relation to stock items, I have 4 columns of date I need to enter into these
sheets. e.g.

Date Stock +/- Stock Total Initials

These are the 4 headings of the columns, what I am looking to do is that I
fill in Date and Stock +/- after that I want to put in initials of person
removing stock e.g KJ then after I have input the initials and hit enter I
want to activate so that after initials are input it will automatically
return to sheet1 "Index of Stock"

Can anyone help me on this code?

Many thanks

Terilad

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default VBA .activate

Good question.

Sheets(1).Activate means to activate the first (left-most) sheet regardless
of its name

Sheets("Index of Stock").Activate means to activate the sheet with the given
tabname regardless of its position
--
Gary''s Student - gsnu200835


"terilad" wrote:

Many thanks Gary''s Student, works a treat, I am a bit confused as I notice
the Index of Stock sheet is actually named as Sheet4 in VBA but this code
works with Sheets (1).activate How is this???

Also I have another 2 Private Sub Worksheet commands on these worksheets, do
these have to be integrated together or are they ok separate as 3 different
commands?

Many thanks

Terilad

"Gary''s Student" wrote:

Put the following event macro in the worksheet code area:

Private Sub Worksheet_Change(ByVal Target As Range)
Set t = Target
Set d = Range("D:D")
If Intersect(t, d) Is Nothing Then Exit Sub
If t.Value = "" Then Exit Sub
Sheets(1).Activate
End Sub
--
Gary''s Student - gsnu200835


"terilad" wrote:

Hi,

I am needing some help with a code, I have 150 sheets in a workbook in
relation to stock items, I have 4 columns of date I need to enter into these
sheets. e.g.

Date Stock +/- Stock Total Initials

These are the 4 headings of the columns, what I am looking to do is that I
fill in Date and Stock +/- after that I want to put in initials of person
removing stock e.g KJ then after I have input the initials and hit enter I
want to activate so that after initials are input it will automatically
return to sheet1 "Index of Stock"

Can anyone help me on this code?

Many thanks

Terilad

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default VBA .activate

Thanks for explaining, much appreciated, did you look at my other question
below about another 2 Private Sub Worksheet commands if they have to be
migrated to one command or if they are ok to remain separate.

Regards

Terilad

"Gary''s Student" wrote:

Good question.

Sheets(1).Activate means to activate the first (left-most) sheet regardless
of its name

Sheets("Index of Stock").Activate means to activate the sheet with the given
tabname regardless of its position
--
Gary''s Student - gsnu200835


"terilad" wrote:

Many thanks Gary''s Student, works a treat, I am a bit confused as I notice
the Index of Stock sheet is actually named as Sheet4 in VBA but this code
works with Sheets (1).activate How is this???

Also I have another 2 Private Sub Worksheet commands on these worksheets, do
these have to be integrated together or are they ok separate as 3 different
commands?

Many thanks

Terilad

"Gary''s Student" wrote:

Put the following event macro in the worksheet code area:

Private Sub Worksheet_Change(ByVal Target As Range)
Set t = Target
Set d = Range("D:D")
If Intersect(t, d) Is Nothing Then Exit Sub
If t.Value = "" Then Exit Sub
Sheets(1).Activate
End Sub
--
Gary''s Student - gsnu200835


"terilad" wrote:

Hi,

I am needing some help with a code, I have 150 sheets in a workbook in
relation to stock items, I have 4 columns of date I need to enter into these
sheets. e.g.

Date Stock +/- Stock Total Initials

These are the 4 headings of the columns, what I am looking to do is that I
fill in Date and Stock +/- after that I want to put in initials of person
removing stock e.g KJ then after I have input the initials and hit enter I
want to activate so that after initials are input it will automatically
return to sheet1 "Index of Stock"

Can anyone help me on this code?

Many thanks

Terilad



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default VBA .activate

You can have several worksheet event macros, but only one of each type.
--
Gary''s Student - gsnu200835


"terilad" wrote:

Thanks for explaining, much appreciated, did you look at my other question
below about another 2 Private Sub Worksheet commands if they have to be
migrated to one command or if they are ok to remain separate.

Regards

Terilad

"Gary''s Student" wrote:

Good question.

Sheets(1).Activate means to activate the first (left-most) sheet regardless
of its name

Sheets("Index of Stock").Activate means to activate the sheet with the given
tabname regardless of its position
--
Gary''s Student - gsnu200835


"terilad" wrote:

Many thanks Gary''s Student, works a treat, I am a bit confused as I notice
the Index of Stock sheet is actually named as Sheet4 in VBA but this code
works with Sheets (1).activate How is this???

Also I have another 2 Private Sub Worksheet commands on these worksheets, do
these have to be integrated together or are they ok separate as 3 different
commands?

Many thanks

Terilad

"Gary''s Student" wrote:

Put the following event macro in the worksheet code area:

Private Sub Worksheet_Change(ByVal Target As Range)
Set t = Target
Set d = Range("D:D")
If Intersect(t, d) Is Nothing Then Exit Sub
If t.Value = "" Then Exit Sub
Sheets(1).Activate
End Sub
--
Gary''s Student - gsnu200835


"terilad" wrote:

Hi,

I am needing some help with a code, I have 150 sheets in a workbook in
relation to stock items, I have 4 columns of date I need to enter into these
sheets. e.g.

Date Stock +/- Stock Total Initials

These are the 4 headings of the columns, what I am looking to do is that I
fill in Date and Stock +/- after that I want to put in initials of person
removing stock e.g KJ then after I have input the initials and hit enter I
want to activate so that after initials are input it will automatically
return to sheet1 "Index of Stock"

Can anyone help me on this code?

Many thanks

Terilad

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default VBA .activate

Many thanks for your help.

Terilad

"Gary''s Student" wrote:

You can have several worksheet event macros, but only one of each type.
--
Gary''s Student - gsnu200835


"terilad" wrote:

Thanks for explaining, much appreciated, did you look at my other question
below about another 2 Private Sub Worksheet commands if they have to be
migrated to one command or if they are ok to remain separate.

Regards

Terilad

"Gary''s Student" wrote:

Good question.

Sheets(1).Activate means to activate the first (left-most) sheet regardless
of its name

Sheets("Index of Stock").Activate means to activate the sheet with the given
tabname regardless of its position
--
Gary''s Student - gsnu200835


"terilad" wrote:

Many thanks Gary''s Student, works a treat, I am a bit confused as I notice
the Index of Stock sheet is actually named as Sheet4 in VBA but this code
works with Sheets (1).activate How is this???

Also I have another 2 Private Sub Worksheet commands on these worksheets, do
these have to be integrated together or are they ok separate as 3 different
commands?

Many thanks

Terilad

"Gary''s Student" wrote:

Put the following event macro in the worksheet code area:

Private Sub Worksheet_Change(ByVal Target As Range)
Set t = Target
Set d = Range("D:D")
If Intersect(t, d) Is Nothing Then Exit Sub
If t.Value = "" Then Exit Sub
Sheets(1).Activate
End Sub
--
Gary''s Student - gsnu200835


"terilad" wrote:

Hi,

I am needing some help with a code, I have 150 sheets in a workbook in
relation to stock items, I have 4 columns of date I need to enter into these
sheets. e.g.

Date Stock +/- Stock Total Initials

These are the 4 headings of the columns, what I am looking to do is that I
fill in Date and Stock +/- after that I want to put in initials of person
removing stock e.g KJ then after I have input the initials and hit enter I
want to activate so that after initials are input it will automatically
return to sheet1 "Index of Stock"

Can anyone help me on this code?

Many thanks

Terilad

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
Reliably activate PowerPoint, do something, Activate Excel Barb Reinhardt Excel Programming 1 December 4th 08 09:42 PM
activate VBA geebee Excel Programming 2 August 17th 07 02:09 AM
activate VBA Gary''s Student Excel Programming 0 August 17th 07 01:53 AM
Windows().Activate vs Workbooks().Activate Gary''s Student Excel Programming 4 November 6th 06 02:01 PM
Workbook.Activate / Window.Activate problem Tim[_44_] Excel Programming 3 February 3rd 06 11:38 PM


All times are GMT +1. The time now is 08:40 AM.

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

About Us

"It's about Microsoft Excel"