Posts by mrmmickle1

    Re: Incorporate save as dialogue box into current vba script


    Maybe use something simple like this:

    Re: Combobox.Value in Range do else


    Maybe try using a Boolean to check if a value matches...once a value matches the "Flag" = True So if the "Flag" = False then you know that no value was found.....


    Re: Watch cell?


    If you want the change event to be triggered in the sheet then leave it, If not then you should turn the event code into a regular macro and then call it from the sort procedure.




    You could also do both....if you want to trigger the change event code you will need to change a cells value like I mentioned:


    Code
    Sub Test() 
         
        'Your Sort Code Here
      
        Sheets("Sheet1").Range("Z1") = "Trigger" ' By putting the value "Trigger" in a cell on the worksheet you have that contains the change event
                                                                  'This will trigger the change event code.....because the worksheet has been changed....
         
    End Sub


    More info on the Worksheet Change Event: https://msdn.microsoft.com/en-…255&MSPPError=-2147217396

    Re: Watch cell?


    I mentioned in a few previous posts how to trigger the macro. Here is how to change the cell color (format) your cells:


    Code
    Sub ColorMyCell()
    
    
    
    
        Range("R1").Interior.Color = 65535 'Yellow
        Range("S1").Interior.Color = 255 'Red
        Range("T1").Interior.Color = 5287936 'Green
      
    End Sub

    Re: Watch cell?


    Quote

    But, can we call change event code from module1 Sort Macro?


    So if you want to run the change code you will need to do something like this....


    Code
    'Sheet 1 code module
    PrivateSub Worksheet_Change(ByVal Target As Range) 
        MsgBox "I have been activated by code in module 1" 
    End Sub


    Module 1 Code:

    Code
    Sub Test() 
         
       'Your Sort Code Here <---------------------------########**************############
         
        Sheets("Sheet1").Range("Z1") = "Trigger" 'Changing a cell on Sheet1 will activate the change event code....
         
    End Sub

    Re: Watch cell?


    I'm still a little confused on what your doing. To activate the change event code on "Sheet1" you have to physically change something on the worksheet.



    So if you want to run the change code you will need to do something like this....


    Code
    'Sheet 1 code module
    Private Sub Worksheet_Change(ByVal Target As Range)
        MsgBox "I have been activated by code in module 1"
    End Sub



    Module 1 Code:

    Code
    Sub Test()
    
    
    'Your Sort Code Here
        
        Sheets("Sheet1").Range("Z1") = "Trigger" 'Changing a cell on Sheet1 will activate the change event code....
        
    End Sub


    If you don't want to change a value on Sheet1, there are many different types of events that you can use...i.e. Selection Change, Activate, DeActivate etc.... in addition you can also change the event code to run a macro from it like this:

    Code
    Private Sub Worksheet_Change(ByVal Target As Range)
         Call MyMacroNameHere
    End Sub


    For formatting times you'll need to convert the times into different segments. Days, Hours & Minutes Then use a series of if statements to determine how to handle the plural... See this thread for reference: http://www.ozgrid.com/forum/showthread.php?t=25985


    you can conditionally format your cells to highlight different cells based on different criteria

    Re: Copy columns to different sheets


    Try this small modification:


    Re: Copy columns to different sheets


    This code works on your sample workbook. If the Table Headers are really bold this should do the trick..... :


    Re: Watch cell?


    Not sure I understand entirely what you're trying to do but I think if you just add these few lines of code to the bottom of your sort macro and leave the event change code as is...it may give you what you want...


    Code
    'Add these to declarations
        Dim ws As Worksheet
        Dim wsTwo As Worksheet
         
        'Add these to the bottom of your code.  After sort is performed....
        Set ws = Sheets("Sheet1")
        Set wsTwo = Sheets("Sheet2")
        wsTwo.Range("B1") = Now() - ThisWorkbook.CustomDocumentProperties("PreviousTimeVal").Value
        ThisWorkbook.CustomDocumentProperties("PreviousTimeVal") = Now()


    Quote

    It has to "refresh" cells containning values even they did't changed, something like this:

    If you're using change event code this occurs like this:


    Code
    Range("B9")= Target.Value



    As I mentioned in my first post: I would recommend tracking the changes in a log.


    You can track when A1 or A2 changes as well as when the Sort Macro is used. The log does not have to be visible it can be hidden....

    Re: Application Match with Multiple criteria


    Maybe something like this will work:


    Code
    Sub Test()
    
    
    On Error Resume Next 'Suppress Errors
    Cells(1, Application.WorksheetFunction.Match("XYZ", Range("1:1"), 0)).Select
    Cells(1, Application.WorksheetFunction.Match("XYZA", Range("1:1"), 0)).Select
    On Error GoTo 0 'Reset Error Handling
    
    
    End Sub

    Re: countdown timer, macro


    Does the Event Fire when every second changes or not? Does the code you wrote work if you cut it down to fewer lines??


    If so you may try something much simpler like this:



    If the event is firing every second then this code should log a value in Column A as well as the timestamp in Column B.... i.e. "00:05:00", "00:04:59"...etc

    Re: countdown timer, macro


    Can you please paste the first 10 or 20 lines of your code? or better yet attach an example file. I'm sure there's a simpler way to accomplish your goal.

    Re: countdown timer, macro


    You shouldn't give up. It's not to bad. Just do the following.


    1. Use Alt + F11 to access the Visual Basic Editor
    2. In the Project Explorer Pane on the left. Double Click the worksheet icon that your Timer is on.
    3. Paste the code in the blank white space on the right.

    Re: countdown timer, macro


    Maybe you can use this worksheet change event:


    Re: Userform - Checkbox and Combobox


    Here's another modification....


    Currently when you click 'Delete' and select 'No'. The ProgressBar appears and additional code is run... instead you can add an Exit Sub line...to stop code in that case:


    i.e.


    Re: using vlookup


    What about something like this:

    Code
    Sheets("Sheet2").Range("A1") = Application.VLookup("MyValue", "'Sheet1'!$A$2:$D$100", 4, false)

    Re: using vlookup


    If you asking for an example of how to do a vlookup there are plenty of them on the web....


    https://exceljet.net/excel-functions/excel-vlookup-function

    http://www.techonthenet.com/excel/formulas/vlookup.php


    http://www.excelfunctions.net/Vlookup-Example-Exact-Match.html


    VLOOKUP( value, table, index_number, [approximate_match] )
    Parameters or Arguments



    value
    The value to search for in the first column of the table.
    table
    Two or more columns of data that is sorted in ascending order.
    index_number
    The column number in table from which the matching value must be returned. The first column is 1.
    approximate_match
    Optional. Enter FALSE to find an exact match. Enter TRUE to find an approximate match. If this parameter is omitted, TRUE is the default.