+ Reply to Thread
Results 1 to 5 of 5

Vba add time based on cell and fill formula

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-16-2009
    Location
    NA
    MS-Off Ver
    MS Excel 2010
    Posts
    237

    Vba add time based on cell and fill formula

    Hi guys. Old problem but new question. In the vba within workbook below I would like to add into it several things:

    • each time I write something in column "c", column "b" must be filled with the actual time (- 15 sec). However, If I

    were to delete a cell in column "C" then the time In "b" would also have to be deleted. Accept only text cells and

    start from row 5 and downwards.


    • if time exists in "b" then fill this formula

    =HYPERLINK(bookpath()&$A5&".264";"Vizionare")
    in column "g". Where "bookpath" is a udf.

    Private Sub Worksheet_Change(ByVal Target As Range)
    
    
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, UserInterfaceOnly:=True
    
    If Target.Cells.Count > 1 Then Exit Sub
    
            If Not Intersect(Target, Range("C5:C400")) Is Nothing Then
    
               With Target(1, 0)
    
                     .Value = Time - TimeValue("00:00:15")
    
                     '.EntireColumn.AutoFit
    
                End With
                
                End If
                      
    
    End Sub
    Attached Files Attached Files
    Last edited by Zaeguzah; 03-31-2010 at 04:50 AM.

  2. #2
    Valued Forum Contributor JeanRage's Avatar
    Join Date
    03-02-2009
    Location
    Nice, France
    MS-Off Ver
    Excel 2003
    Posts
    705

    Re: Vba add time based on cell and fill formula

    Hi,

    See attached ...

    HTH
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    07-16-2009
    Location
    NA
    MS-Off Ver
    MS Excel 2010
    Posts
    237

    Re: Vba add time based on cell and fill formula

    Perfect. Thanks my friend. One more thing if you have the time.. If I select a cell at a time in column "C" the time and the formula gets deleted. Fine but if I select a range from column "C", ie: C5:C20 for instance then nothing gets deleted. Any possble fix for this?

    Thanks for your help,
    Alex

  4. #4
    Valued Forum Contributor JeanRage's Avatar
    Join Date
    03-02-2009
    Location
    Nice, France
    MS-Off Ver
    Excel 2003
    Posts
    705

    Re: Vba add time based on cell and fill formula

    Hi,

    Adjust the range to your needs ...
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim c As Range
    If Not Intersect(Target, Range("A5:A20")) Is Nothing Then
        For Each c In Target.Cells
            If Not IsEmpty(c) Then
                c.Offset(0, 1).Value = Time - TimeValue("00:00:15")
                c.Offset(0, 6).Formula = "=HYPERLINK(bookpath()&$A5&"".264"",""Vizionare"")"
            Else
                c.Offset(0, 1).ClearContents
                c.Offset(0, 6).ClearContents
            End If
        Next c
    End If
    End Sub
    HTH
    Last edited by JeanRage; 03-31-2010 at 10:37 AM.

  5. #5
    Forum Contributor
    Join Date
    07-16-2009
    Location
    NA
    MS-Off Ver
    MS Excel 2010
    Posts
    237

    Re: Vba add time based on cell and fill formula

    Thanks man. Like a charm as always. SOLVED

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1