Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 130
Default Same macro - Different Worksheets!?

I have a spreadsheet that looks has two criteria.

1. Must not go over a set number
2. Must not allow entry past a certain date.

This code is working but i have serveral places (one on each worksheet) that
this needs to work for.

Eg/ Booking in for Manchester, Bristol, Birmingham and Sheffield, i have a
workbook one for each place.

When i place the code in each worksheet (its a worksheet_calculate macro) it
reads the information from the other worksheets and will not work.

i also tried placing the code within the ThisWorkbook section but the code
just does not work!

Any ideas as to how i can get this code to work?

thanks
PaulW

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 43
Default Same macro - Different Worksheets!?


Hi Paul,

Do we have the names of the sheets in the code? Or is it a generic code
should should work for all the sheets.


Regards
Ankur
www.xlmacros.com

On Dec 12, 4:25 pm, PaulW wrote:
I have a spreadsheet that looks has two criteria.

1. Must not go over a set number
2. Must not allow entry past a certain date.

This code is working but i have serveral places (one on each worksheet) that
this needs to work for.

Eg/ Booking in for Manchester, Bristol, Birmingham and Sheffield, i have a
workbook one for each place.

When i place the code in each worksheet (its a worksheet_calculate macro) it
reads the information from the other worksheets and will not work.

i also tried placing the code within the ThisWorkbook section but the code
just does not work!

Any ideas as to how i can get this code to work?

thanks
PaulW


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 130
Default Same macro - Different Worksheets!?

Please find the code below, i am useing activeSheet / Cell / Address to
define the different sheets

Private Sub Worksheet_Calculate()

today = Range("B4").Value
shee = ActiveSheet.Name
rang = ActiveCell.Column
addres = ActiveCell.Address
Valu = Sheets(shee).Cells(5, rang + 3).Value
dat = Sheets(shee).Cells(6, rang + 1).Value
dat2 = Sheets(shee).Cells(6, rang + 6).Value
num = 0

If rang = 2 Then num = 8
If rang = 8 Then num = 14
If rang = 14 Then num = 2
If num = 0 Then Exit Sub

If Valu Range("J1").Value Then
MsgBox ("The Number has reached its limit. Please use the next slot. (" &
dat2 & ")")
Selection.End(xlUp).Select

addres = ActiveCell.Address
act = Range(addres).Value

Selection.ClearContents
Sheets(shee).Cells(10, num).Select
ActiveCell.Value = act

Else: End If

If today dat Then
MsgBox ("The Cut off point has been reached for this slot. Please use the
next available slot. (" & dat2 & ")")
Selection.End(xlUp).Select

addres = ActiveCell.Address
act = Range(addres).Value

Selection.ClearContents
Sheets(shee).Cells(10, num).Select
ActiveCell.Value = act

Else: End If

End Sub


"ankur" wrote:


Hi Paul,

Do we have the names of the sheets in the code? Or is it a generic code
should should work for all the sheets.


Regards
Ankur
www.xlmacros.com

On Dec 12, 4:25 pm, PaulW wrote:
I have a spreadsheet that looks has two criteria.

1. Must not go over a set number
2. Must not allow entry past a certain date.

This code is working but i have serveral places (one on each worksheet) that
this needs to work for.

Eg/ Booking in for Manchester, Bristol, Birmingham and Sheffield, i have a
workbook one for each place.

When i place the code in each worksheet (its a worksheet_calculate macro) it
reads the information from the other worksheets and will not work.

i also tried placing the code within the ThisWorkbook section but the code
just does not work!

Any ideas as to how i can get this code to work?

thanks
PaulW



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
Macro to Compare Two Worksheets? V. Hatherley Excel Discussion (Misc queries) 2 August 13th 06 02:33 AM
Saving worksheets using a Macro lqfong Excel Discussion (Misc queries) 1 June 27th 06 01:10 PM
Running Same macro in 250 Worksheets in Same Workbook halem2 Excel Worksheet Functions 3 March 24th 06 08:51 AM
Applying same macro to all worksheets in workbook [email protected] Excel Discussion (Misc queries) 2 October 19th 05 11:25 PM
CREATE MACRO TO COPY MULTIPLE WORKSHEETS Bewilderd jim Excel Discussion (Misc queries) 5 March 3rd 05 10:00 PM


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