Posts by W@rrior

    Re: Translate This Code For Me?


    Actually, stepping through the code would be a more benefic solution for you. Make sure you can see the spreadsheet behind the VBA Editor window, and click anywhere within the Macro code. Then press F8 to step through each line, see what's happening in the spreadsheet.

    Re: Alphabetical Sort Of Data Within A Cell


    Hello dsutton!


    I always enjoy a good challenge when I find one...


    I've tested this, and it seems to work...


    Obviously it's considering only cell A12 like you mentionned in your example. Therefore you will need to slightly adapt the code to cycle through all 12000 entries... ;)



    Hope this works for you...

    Re: Simplifying Code


    Hi Oleo!


    Try something like this :



    what you put in get_a through get_o is up to ya...



    Cya!

    Re: Determine Preferred Mail Program


    Quote

    Sweet!


    Please post a code snippet once it's finalized so other searchers will have a solution.


    After barging in to my boss' office, I got him to "standardize" the mail programs to either Windows Mail (Outlook Express) or Microsoft Outlook. ([COLOR="Lime"]Weeee![/COLOR])


    On to the code:


    Of course this function is part of a bigger code to generate the e-mail & attach file for either mailer program. If needed to help others, I'd gladly attache the code snippet to another reply...

    Hi!


    I'm running a macro that sends an E-Mail with an attachement depending on the value of a specific cell. This code will be run on any of the computers on our network.


    I got my macro to either use Outlook or Outlook Express, but since some of the users use either of the programs, I need to be able to determine the preferred mail program they are using. (If only they'd be willing to standardize... 8-) ... )


    Does anyone know any trick I might be overlooking?


    Thanx!

    Re: Extracting A Value From The Title Of The Workbook


    Quote from ArtieFish

    And thank you W@arrior.


    If you don't mind W@rrior, could you just step me through what the code is actually doing. I have a good idea, but it's not all coming together properly for me.


    Thanks


    Ok here goes :


    Len(ActiveWorkbook.Name) will return the lenght of the activeworkbook.name string.
    Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 4) will trim down the .XLS part of workbookname.
    Right(Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 4), 4) will take the last 4 characters starting from the right of the string, that was stripped of it's extension.


    Of course, that's all assuming the workbook name will always finish with a 4-digit year number. ;)

    Re: Extracting A Value From The Title Of The Workbook


    Assuming you are talking about the workbook name, something like this should work fine :


    Code
    Sub ExtractYear()
        BookName = ActiveWorkbook.Name
        BookName = Left(BookName, Len(BookName) - 4)
        BookNameYear = Right(BookName, 4)
        Range("A1") = BookNameYear
    End Sub


    Or Simplified :

    Code
    Sub ExtractYear()
        Range("B1") = Right(Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 4), 4)
    End Sub


    Use either as you prefer... Although option 2 makes for smaller code.

    Re: Allow Use Of Workbook On Specific Computers Only


    Sounds more like a security-level access question that the network administrator at your company might solve. (ie: Under Windows, create a special policy group containing the users who have rights to open/modify/delete the file, and enforce the policy to said file)


    (of course, that's if memory serves, as I haven't done that in 8 years) Hehehe! :)

    Re: If Statement Within For...next Loop


    Quote from bobwhosmiles
    Code
    totalRowCount = ActiveSheet.UsedRange.Rows.Count
                
                For rowCounter = 16 To totalRowCount
                    sourceCell = "B" & rowCounter
    
    
                    ActiveSheet.Cells(rowCounter, 12).Formula = _
                        "=IF(LEN(" & sourceCell & ")<=10,TEXT(" & sourceCell & ",""dd/mm/yyyy""),"""")"
                Next rowCounter


    Add the red lines to your code :


    Code
    totalRowCount = ActiveSheet.UsedRange.Rows.Count
                
                For rowCounter = 16 To totalRowCount
                    sourceCell = "B" & rowCounter
    [COLOR="red"]IF Not ActiveSheet.Range(sourceCell).Value = "A" or "B" or "C" then[/COLOR]
                         ActiveSheet.Cells(rowCounter, 12).Formula = _
                        "=IF(LEN(" & sourceCell & ")<=10,TEXT(" & sourceCell & ",""dd/mm/yyyy""),"""")"
    [COLOR="Red"]End If[/COLOR]
                Next rowCounter


    Should do the trick.

    Re: Offset Cell Value Based On Criteria


    Hi!


    Your code seems Okay to me...


    One questions though, in the following lines


    Code
    FindWhat =  Array("BB", "B", "CCC", "CC", "C", "CCC+") 
        For i = 0 To 3


    Why is i set from 0 to 3 if it's to cycle through the array which holds 6 elements?


    Did you set the cell format to be percentage?