LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
PK PK is offline
external usenet poster
 
Posts: 69
Default Function updating all worksheets in workbook

I have a function in VBA as detailed at the end of my text and it is updating
all worksheets in a workbook rather than just the active one. I have 12
worksheets all identical apart from Column 2 which holds consecutive date
data (hence one sheet per month). Cell A2 shows the current date on all
worksheets. My cell formula on each worksheet is =addtimeb(C3:CN3,"H") which
changes for each subsequent row for a number of rows ie
=addtimeb(D3:DN3,"H")
=addtimeb(E3:EN3,"H")
=addtimeb(F3:FN3,"H") etc etc each row is an employee record.
I am extracting and summing numbers, from string text fields, that follow a
"H" (for holiday) and where column 2 has a date <= the current date (cell
A2). However when I amendd ata on any sheet it automatically updates all
sheets but only takes into account the dates in column 2 on the active sheet.
Hence data held on the remaining 11 sheets becomes inaccurate.

Function addtimeb(rng As Range, ltr As String)
Application.Volatile
Dim ts As String
Dim x As Long
Dim DateRow As Long
ltr = UCase(ltr)
For Each c In rng
If Cells(2, c.Column).Value Range("A2").Value Then GoTo getmeout
If InStr(UCase(c.Value), ltr) 0 Then
For x = InStr(UCase(c.Value), ltr) To Len(c.Value)
If IsNumeric(Mid(c.Value, x, 1)) Or Mid(c.Value, x, 1) = "." Then
ts = ts + Mid(c.Value, x, 1)
If Not IsNumeric(Mid(c.Value, x + 1, 1)) And _
Mid(c.Value, x + 1, 1) < "." Then Exit For
End If
Next
End If
If ts < "" Then
addtimeb = addtimeb + Val(ts)
ts = ""
End If
getmeout:
Next
End Function

Thank you.

--
PK wilts
 
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
SUM function across multiple worksheets within one workbook John Reimer Excel Worksheet Functions 4 January 24th 08 02:04 AM
My workbook links are not updating (its 30,000 KB size workbook). rselena Excel Discussion (Misc queries) 1 August 14th 06 09:14 PM
Auto updating a workbook with data from another workbook Richard Excel Discussion (Misc queries) 0 November 6th 05 03:50 PM
Updating multiple worksheets in a large workbook Graham Excel Discussion (Misc queries) 3 February 11th 05 10:29 AM
updating excel worksheets to another workbook Phil Excel Worksheet Functions 1 December 16th 04 03:17 AM


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

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"