Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 135
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I clear 'form' content from an unprotected cell without mac Casey M Excel Worksheet Functions 4 January 22nd 09 07:10 PM
PROBLEMS WITH SUM AND PRODUCT NOT WORKING AFTER I CLEAR CONTENT. Richard Excel Discussion (Misc queries) 0 July 26th 07 05:32 PM
How to clear content from unprotected Field Amean1 Excel Worksheet Functions 1 November 11th 06 07:50 PM
Clear Cells Content No_Spam Excel Discussion (Misc queries) 2 August 20th 06 04:01 PM
How do I clear cell content when excel document is closed? m3155 Excel Worksheet Functions 1 February 25th 05 11:23 AM


All times are GMT +1. The time now is 04:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"