Results 1 to 5 of 5

Thread: Clear Cell Value before re-running the VBA

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,709
    Location
    First; We strongly suggest that you use Option Explicit in all your code.

    Second; "+" is a math operator. It is best practice to always use "&" to concatenate Strings.

    Third; It is best practice to never use Public Variables unless the procedure must modify them for use in another procedure. As written, we, and maybe VBA, can't know enough about strCurrentTime and StaticTime to properly parse your code.

    Fourth; Without using Option Explicit, it is possible that strTarget is seen by VBA as an Cell Index and strCurrentRow as a Long so that adding (+) the two results in refering to a different Cell than you think.

    Fifth; Value2 only applies to a Range Collection. Therefore when you Add (+) two variables that can be construed by VBA as Ranges and use a Range Collection Property, Value2, VBA may combine the two Variables as Ranges.

    Sixth; Unless you have a good reason to assign a different time than the current time to the Cell represented by strDestination, substitute "Now" for "StaticTime."

    Seventh; If you are working with Ranges, Use Range Vars, not String Vars.

    Finally; This collage of lines in your code show the confusion generated by it.
    [vba]
    ' Checks for a Yes or NA or RB(Rollback) value in strTarget
    ' Check to see if strTarget changes to "No" but originally was yes
    '
    'If (Range(strDestination + strCurrentRow).Value2 Like ("Rolled Back*")) Then
    'If Not (Range(strDestination + strCurrentRow).Value2 Like "*RB*") Then
    [/vba]


    You will need to attach the workbook for us to be able to fully understand your code.
    Last edited by SamT; 02-22-2010 at 07:28 AM.

Posting Permissions

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