VBA Tab Numbers

zyhin

Board Regular
Joined
Oct 8, 2009
Messages
78
Hi all I have a code that I'm trying to get to work and I am lost to know why it doesnt work.

I have many worksheets, the first is named "Welcome" the rest are named employee numbers ranging from 100 to 999. However the numbers are for every employee that ever worked for our company and now have gaps in the numbering of the tabs due to people leaving the company. e.g. 100, 101, 105, 130, 145, 250 and so on. I am trying to get a macro to run at 11:00am so that this will clock them out for lunch. This needs to be done on every worksheet other then the "welcome" sheet.

Code:
Sub LunchTimeStart()
 
Application.OnTime TimeValue("11:00:00"), "LunchTimeStart"
 
Dim TabNumber%
 
LastRow = Worksheets(TabNumber).Cells.Find(what:="*", searchdirection:=x1Previous, searchorder:=x1ByRows) .Row
 
For TabNumber = 100 to 999
      Worksheets(TabNumber).Cells(LastRow, 6).Value = Time
      Worksheets(TabNumber).Cells(LastRow, 7).Value = "hh:mm:ss;@"
      Worksheets(TabNumber).Cells(LastRow, 6).Formula = Worksheets(TabNumber).Cells(LastRow, 6) - Worksheets(TabNumber).Cells(LastRow, 5)
Next TabNumber
 
End Sub

Hope you all can help.

Zyhin
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
If there's only one sheet you need to exclude I'd probably just go with this:

Code:
Sub Foo()
  Dim ws as worksheet
    For each ws in ActiveWorkbook.Worksheets
      If ws.Name <> "Welcome" Then
        with ws
           '  Do your thing here
        End with
      End If
   Next ws
End Sub

HTH,
 
Upvote 0

Forum statistics

Threads
1,224,504
Messages
6,179,144
Members
452,891
Latest member
JUSTOUTOFMYREACH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top