Posts by moshjosh

    Re: Input box to gather date range and sort list using VBA


    Quote from Luke M;725356

    Hello moshjohs.


    This sounds like a perfect place to use an Advanced Filter. Take a look at the attached, or see link for more info.
    http://www.contextures.com/xladvfilter01.html



    Hi Luke, Thank you for your input but this does not solve my problem. My requirements included the filter via vba code and input box for user input of date ranges. Have you got any other solution which covers this?

    Hi fellow VBA lovers,


    I would love a solution to help me do the follow:


    'Sort' (i.e. push all applicable rows of data which match my criteria to the top of a list, as opposed to just filtering out the irrelevant dates) a list of scheduled courses to the top of my data set based on a date range ('start' and 'end' dates) in Excel 2010. The dates will be provided by the user via an 'Input box' which will pop up at the start when the code is run.


    It would be great if the sorted data could be copied and pasted into a new worksheet called 'sorted data'. Tall order but I would be massively grateful of a solution. Cheers


    Sample In-Put box:
    [TABLE="class: grid, width: 191"]

    [tr]


    [TD="colspan: 2"]Please enter the data range your wish to sort by?:
    [/TD]

    [/tr]


    [tr]


    [td]

    Date range 'Start'

    [/td]


    [td]

    Date range 'End'

    [/td]


    [/tr]


    [tr]


    [td]

    10/08/2014 09:00

    [/td]


    [td]

    14/08/2014 09:30

    [/td]


    [/tr]


    [/TABLE]



    • My data starts in Cell A5
    • The table headers are in row 4
    • My data table has 32 colums
    • and 'X' number of rows (usually about 3,000)


    An example of my data is below 'dates' to sort by will be present in column B.



    [TABLE="class: grid, width: 719, align: left"]

    [tr]


    [td]

    UID ID

    [/td]


    [td]

    Start Date

    [/td]


    [td]

    Last Date

    [/td]


    [td]

    Course UID

    [/td]


    [td]

    Course Title

    [/td]


    [td]

    Status

    [/td]


    [/tr]


    [tr]


    [td]

    100909

    [/td]


    [td]

    10/08/2014 09:00

    [/td]


    [td]

    19/08/2014 17:00

    [/td]


    [td]

    JPCVBA

    [/td]


    [td]

    VBA for complete novice


    [/td]


    [td]

    Cancelled

    [/td]


    [/tr]


    [tr]


    [td]

    100908

    [/td]


    [td]

    12/08/2014 09:30

    [/td]


    [td]

    11/08/2014 12:30

    [/td]


    [td]

    JPCMIR

    [/td]


    [td]

    Baking in the Microwave

    [/td]


    [td]

    Active

    [/td]


    [/tr]


    [tr]


    [td]

    100907

    [/td]


    [td]

    14/08/2014 09:30

    [/td]


    [td]

    12/08/2014 17:30

    [/td]


    [td]

    JPCPLU

    [/td]


    [td]

    Plumbing 101

    [/td]


    [td]

    Cancelled

    [/td]


    [/tr]


    [tr]


    [td]

    100906

    [/td]


    [td]

    02/08/2014 09:30

    [/td]


    [td]

    14/08/2014 17:30

    [/td]


    [td]

    JPCDIY

    [/td]


    [td]

    DIY for the accident prone

    [/td]


    [td]

    Active

    [/td]


    [/tr]


    [tr]


    [td]

    100905

    [/td]


    [td]

    25/08/2014 09:30

    [/td]


    [td]

    14/08/2014 17:30

    [/td]


    [td]

    JPCCHA

    [/td]


    [td]

    How to dance the cha-cha-cha

    [/td]


    [td]

    Cancelled

    [/td]


    [/tr]


    [tr]


    [td]

    100902

    [/td]


    [td]

    18/08/2014 09:30

    [/td]


    [td]

    14/08/2014 17:30

    [/td]


    [td]

    JPCDIY

    [/td]


    [td]

    DIY for the accident prone

    [/td]


    [td]

    Active

    [/td]


    [/tr]


    [/TABLE]

    Re: Can Countif be case sensitive


    Hi A9192Shark,
    I'm not that familiar with VB; where within the VBA editor does the code go? Also what formula do I type into the formula bar once the code is in the right place? Does it work across all worksheets or just the one I apply the code to?


    I have attached a screen-shot of my VBA editor if this helps. Many thanks in advance.


    [ATTACH=CONFIG]45683[/ATTACH]


    Quote from A9192Shark;140530

    JP2004,


    or this function which is a simplified version of countif for your situation:

    Code
    Public Function CountifCaseSensitive(rngEvaluate As Range, _
    strCriteria As String) As Long
        Dim rng         As Range
        Dim lngCount    As Long
        lngCount = 0
        For Each rng In rngEvaluate
            If rng = strCriteria Then lngCount = lngCount + 1
        Next rng
        CountifCaseSensitive = lngCount
    End Function


    A.

    Display a message box which displays cell address of the last populated cell in a row and jumps to 'it' when user clicks “ yes “ button



    I am a complete novice to VBA. Is there a cleaner way to write some VBA code performing the following function?


    When macro is run:



    • Displays popup message box with text.
    • Runs string of VBA code which returns cell address of last populated cell in column "A" and displays it as follows: "Last Populated Cell Is: [Cell Address] Jump To The Last Cell?"
    • Gives user chose of "Yes" or "No"


    • If user choose YES = Jumps to last populated cell.
    • If user choose NO = macro ends and pop box disappears.


    Here is my code at present: