Posts by tinyjack

    Re: Basic "If, Then" Formula


    Your ANDs are going to always fail as you either have the wrong references ie AND(F7=$F$15,F7<$F$15) or the wrong comparisons ie AND(F7=$F$14,F7<$F$15). I would expect that you need:


    =IF(F7<$F$14,"Tier 0",IF(AND(F7>=$F$14,F7<$F$15),"Tier 1",IF(AND(F7>=$F$15,F7<$F$16),"Tier 2",IF(F7>=$F$16,"Tier 3","Error"))))


    HTH


    TJ


    ps You might to have a look at VLOOKUP as this could be another way to go.

    Re: ActiveWorkbook


    It depends on what you mean by get your code to work on the whole workbook.


    There is 'ActiveWorkbook' which will the currently active workbook object, which you can then apply any of the Workbook object methods to or set any of the Workbook object properties.


    However, if you mean work with all the the worksheets you could maybe use something like:


    [vba]
    Dim wsItem As Worksheet


    For Each wsItem In ActiveWorkbook.Worksheets
    'Do what you want, for example
    Debug.Print wsItem.Name
    Next
    [/vba]


    HTH


    TJ



    Edit - No buses for 15 minutes and then along come 3

    Re: Formula for TIME to DECIMAL


    If your data is in time format, then tou can sum them and then multiply by 24 to give you decimal hours. You will need to format the result to General or other number format.


    TJ

    Re: Reverse Dynamic Chart Headache


    You are very close, use this for your named range AVERAGE:


    =OFFSET(Sheet1!$A$1,7,MONTH(Sheet1!$A$10)+(YEAR(Sheet1!$A$10)-2003)*12,1,-12)


    and adjust your other ranges on the same lines.


    HTH


    TJ

    Re: Using the INDIRECT Function


    You could use something like this:


    [vba]
    Public Function FindReturn(rngValue As Range, rngSeek As Range, rngReturn As Range) As Variant


    'rngValue : What are you looking for
    'rngSeek : Which cell are you checking on each sheet
    'rngReturn : Which cell do you wish to return from the found sheet


    Dim wsItem As Worksheet


    FindReturn = CVErr(xlErrNA)


    For Each wsItem In ThisWorkbook.Worksheets


    If wsItem.Cells(rngSeek.Row, rngSeek.Column).Value = rngValue.Value Then
    FindReturn = wsItem.Cells(rngReturn.Row, rngReturn.Column).Value
    End If

    Next


    End Function
    [/vba]


    You would need to add some error checking (ie ranges not 1 cell) and at present it is case sensistive.


    HTH


    TJ


    EDIT - Posted before comment about Workbooks

    Re: VBA vLookup


    Vlookup will produce a runtime error if the value being search for cannot be found. It is something that you have to trap:


    [vba]
    On Error Resume Next


    'Put Vlookup here


    If Err.Number <> 0 Then
    'Not found
    'Write out error
    Debug.Print Err.Number
    Debug.Print Err.Description
    Else
    'Found
    End If


    On Error GoTo 0 ' or On Error Goto YourErrorTrap
    [/vba]


    HTH


    TJ