Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Clear Cell Content Query
Hi there My Excel Vba shown below inserts time() into a particular cell on my sheet. Once inserted, is it possible to clear this cell before my vba code is re-run?. My VBA is only entering the time() once and not re-insering the time() if i change the same cell values after some time i.e. please advice Below is my code which inserts time() into a cell. Private Sub DateModifier(ByVal strTarget As String, ByVal strDestination As String) ' Checks for a Yes or NA or RB(Rollback) value in strTarget and if found, modifies the cell in strDestination If (Range(strTarget + strCurrentRow).Value2 = "Yes") Then If (Range(strDestination + strCurrentRow).Value2 = "") Then Range(strDestination + strCurrentRow).Value2 = StaticTime End If ' Check to see if Log has been rolled back If (Range(strDestination + strCurrentRow).Value2 Like ("Rolled Back*")) Then Range(strDestination + strCurrentRow).Value2 = StaticTime End If End If ' Check for an NA status If (Range(strTarget + strCurrentRow).Value2 = "NA") Then If (Range(strDestination + strCurrentRow).Value2 = "") Then Range(strDestination + strCurrentRow).Value2 = "NA" End If End If ' Check to see if strTarget changes to "No" but originally was yes ' (if a value is in strDestination we assume a log has happened) ' and append the log with Rolled Back and the date If (Range(strTarget + strCurrentRow).Value2 = "RB") Then If Not (Range(strDestination + strCurrentRow).Value2 = "") Then If Not (Range(strDestination + strCurrentRow).Value2 Like "*RB*") Then Range(strDestination + strCurrentRow).Value2 = "RB" + StaticTime End If End If End If End Sub -- captedgar |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Clear Cell Content Query
Captedgar -
Of course you can clear it manually before you run the code. Better, clear it at the top of the code you are running. Like this: Private Sub DateModifier(ByVal strTarget As String, ByVal strDestination As String) Range(strDestination + strCurrentRow).Value2 = "" 'Empty out this field to start with. ' Checks for a Yes or NA or RB(Rollback) value in strTarget and if found, modifies the cell in strDestination If (Range(strTarget + strCurrentRow).Value2 = "Yes") Then If (Range(strDestination + strCurrentRow).Value2 = "") Then Range(strDestination + strCurrentRow).Value2 = StaticTime End If -- Daryl S "captedgar" wrote: Hi there My Excel Vba shown below inserts time() into a particular cell on my sheet. Once inserted, is it possible to clear this cell before my vba code is re-run?. My VBA is only entering the time() once and not re-insering the time() if i change the same cell values after some time i.e. please advice Below is my code which inserts time() into a cell. Private Sub DateModifier(ByVal strTarget As String, ByVal strDestination As String) ' Checks for a Yes or NA or RB(Rollback) value in strTarget and if found, modifies the cell in strDestination If (Range(strTarget + strCurrentRow).Value2 = "Yes") Then If (Range(strDestination + strCurrentRow).Value2 = "") Then Range(strDestination + strCurrentRow).Value2 = StaticTime End If ' Check to see if Log has been rolled back If (Range(strDestination + strCurrentRow).Value2 Like ("Rolled Back*")) Then Range(strDestination + strCurrentRow).Value2 = StaticTime End If End If ' Check for an NA status If (Range(strTarget + strCurrentRow).Value2 = "NA") Then If (Range(strDestination + strCurrentRow).Value2 = "") Then Range(strDestination + strCurrentRow).Value2 = "NA" End If End If ' Check to see if strTarget changes to "No" but originally was yes ' (if a value is in strDestination we assume a log has happened) ' and append the log with Rolled Back and the date If (Range(strTarget + strCurrentRow).Value2 = "RB") Then If Not (Range(strDestination + strCurrentRow).Value2 = "") Then If Not (Range(strDestination + strCurrentRow).Value2 Like "*RB*") Then Range(strDestination + strCurrentRow).Value2 = "RB" + StaticTime End If End If End If End Sub -- captedgar . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I clear 'form' content from an unprotected cell without mac | Excel Worksheet Functions | |||
PROBLEMS WITH SUM AND PRODUCT NOT WORKING AFTER I CLEAR CONTENT. | Excel Discussion (Misc queries) | |||
How to clear content from unprotected Field | Excel Worksheet Functions | |||
Clear Cells Content | Excel Discussion (Misc queries) | |||
How do I clear cell content when excel document is closed? | Excel Worksheet Functions |