vba conditional action

  • Dear all


    I would be very grateful if someone could help me solve the following problem. I have been working on the following part of my program for quite sometime and I have finished all bar this final section.



    I would be very grateful if someone could tell me how I could introduce a if/else statement to say if (for the next line of code) rngcheque is nothing


    Code
    objwsk2.Range("a" & introw) = "ADNPCPT" & strrefdate & Format(Now(), "hhmm")


    else


    Code
    objwsk2.Range("a" & introw) = rngcheque



    If any one can solve this and the code still work I would be extremely grateful


    Kindest Regards

    Andrew Nellies


    VBA Learner seeking advice and guidance


    :thanx:

  • Re: vba conditional action


    adncmm,


    How about:


    Code
    if rngcheque = 0 then
    'yourcode
    Else
    'your other code
    End If



    NB: use 0 to detect a cell that contains a zero value, use "" to detect an empty cell


    Regards
    Weasel

  • Re: vba conditional action


    Hi Weasel,


    Thanks for the reply


    Just one question?


    By using this code would it not allways look in the orginal cell (rngfoundcells.offset(0,1)) instead of moving down to the next row like the rest of the values.

    Code
    If rngcheque = 0 Then 
         'yourcode
    Else 
         'your other code
    End If


    I may be talking rubbish but I think I am right in thinking this


    I would be grateful if you could clarify


    Kindest Regards

    Andrew Nellies


    VBA Learner seeking advice and guidance


    :thanx:

  • Re: vba conditional action


    Difficult to tell with only some of code and no real idea of the desired end result. See below - you will need to edit the End If statements depending on the desired result. As the offset enumeration is dependant on the range given by rngimport it should find the cell 8 spaces to the right of the cell referred to by this variable each time.


    Post back if this doesnt have the desired effect.


    Regards
    Weasel


Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!