Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Run-time error '1004':

I'm getting a really hard error when I code to put a formula into a worksheet
that works as a normal formula in the worksheet. I'm building 500 tables
(worksheet B) that contain detailed breakdown data for each single entry in
another worksheet (Worksheet A). So for each Worksheet A entry there is a
detailed breakdown table. I'm trying to write code to create the remaining
499 other tables. This is a one time use of code (vice creating each one
manually that cannot be done by recording a macro and running it) to save
time. I'm stuck on this:

Run-time error '1004':

Application-defined or object-defined error

The code above this works fine but this generates the error:

'Now Fix the Formulas for Effort Hours
Worksheets("Data-Tables").Range("F" & (STARTCELL + (OFFSET * _
LoopCounter) + 3)).Formula = "=IF(Utilize_Nominal_Estimate, _
IF(ISERROR((((E626/$E$617)*$C$565)*Sizing!$Z$6)), 'No Entry', _
(((E626/$E$617)*$C$565)*Sizing!$Z$6)), _
IF(ISERROR((((E626/$E$617)*$C$565)*Sizing!$O$6)), 'No Entry', _
(((E626/$E$617)*$C$565)*Sizing!$O$6)))"

I had to break this line up a little more to make it readable here. If I
don't use the ISERROR code the thing runs fine. However, with it the code
crashes. I've started with the formula copied of the worksheet that already
works start using loopcounters, offsets, and such to fix the hard references
to point the the right cells.

Any ideas?

Thanks,

Bryan

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 132
Default Run-time error '1004':

Here is a method that relies on a custom user-defined function.

Put this formula in a cell on your summary page:
=SumSalaries( 5/15/2005, "Sum1", "Sum3", "A1", "B1" )
Sum1 and Sum3 are the first and last individual sheets, respectively. All
other individual sheets must be between these two sheets.
A1 is the address that contains the date to check on each individ. sheet and
B1 is the address to sum (tuition).


Put this code in a module in your visual basic editor:

Public Function SumSalaries(strCheckDate As String, strSheetStart As String,
strSheetEnd As String, strAddressCheck As String, strAddressSum As String) As
Double
Application.Volatile

Dim wkb As Workbook
Dim wks As Worksheet
Dim lngStart As Long
Dim lngEnd As Long
Dim i As Long
Dim dblTotal As Long

Set wkb = ThisWorkbook

If (Not (ExcelSheetExists(wkb, strSheetStart))) Then
Call MsgBox("Sheet (" & strSheetStart & ") does not exist!")
Exit Function
End If

If (Not (ExcelSheetExists(wkb, strSheetEnd))) Then
Call MsgBox("Sheet (" & strSheetEnd & ") does not exist!")
Exit Function
End If

lngStart = wkb.Worksheets(strSheetStart).Index
lngEnd = wkb.Worksheets(strSheetEnd).Index

strCheckDate = Format(strCheckDate, "mm/dd/yyyy")
dblTotal = 0

For i = lngStart To lngEnd
Set wks = wkb.Worksheets(i)
If (Format(wks.Range(strAddressCheck).Value, "mm/dd/yyyy") =
strCheckDate) Then
dblTotal = dblTotal + wks.Range(strAddressSum).Value
End If
Next i

SumSalaries = dblTotal

Set wkb = Nothing

End Function


Public Function ExcelSheetExists(wkb As Workbook, strSheet As String) As
Boolean
Dim wks As Worksheet

On Error GoTo ErrHandler

Set wks = wkb.Worksheets(strSheet)
ExcelSheetExists = True

Exit Function
ErrHandler:
ExcelSheetExists = False
End Function








"Type of Sheet displayed" wrote:

I'm getting a really hard error when I code to put a formula into a worksheet
that works as a normal formula in the worksheet. I'm building 500 tables
(worksheet B) that contain detailed breakdown data for each single entry in
another worksheet (Worksheet A). So for each Worksheet A entry there is a
detailed breakdown table. I'm trying to write code to create the remaining
499 other tables. This is a one time use of code (vice creating each one
manually that cannot be done by recording a macro and running it) to save
time. I'm stuck on this:

Run-time error '1004':

Application-defined or object-defined error

The code above this works fine but this generates the error:

'Now Fix the Formulas for Effort Hours
Worksheets("Data-Tables").Range("F" & (STARTCELL + (OFFSET * _
LoopCounter) + 3)).Formula = "=IF(Utilize_Nominal_Estimate, _
IF(ISERROR((((E626/$E$617)*$C$565)*Sizing!$Z$6)), 'No Entry', _
(((E626/$E$617)*$C$565)*Sizing!$Z$6)), _
IF(ISERROR((((E626/$E$617)*$C$565)*Sizing!$O$6)), 'No Entry', _
(((E626/$E$617)*$C$565)*Sizing!$O$6)))"

I had to break this line up a little more to make it readable here. If I
don't use the ISERROR code the thing runs fine. However, with it the code
crashes. I've started with the formula copied of the worksheet that already
works start using loopcounters, offsets, and such to fix the hard references
to point the the right cells.

Any ideas?

Thanks,

Bryan

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
synchronizing timestamp feature with time on video software. 999 Excel Discussion (Misc queries) 4 July 30th 06 10:49 PM
formula to determine time range overlap? William DeLeo Excel Discussion (Misc queries) 0 June 6th 06 08:26 PM
Hot key for time? Dave in Des Moines Excel Worksheet Functions 2 March 24th 06 04:15 PM
time sheet drop down lists Steve Excel Discussion (Misc queries) 12 March 18th 06 10:30 PM
time differences in a column 68magnolia71 Excel Worksheet Functions 3 May 9th 05 09:46 PM


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