none
VBA skips code when "NA" is returned for previous line. RRS feed

  • Question

  • Hi,

    I have a project vba which updates tasks from a Excel file.It creates a summary task and then subtasks.And for each summary and sub tasks some attributes are set.This is done by a separate sub routine.

    My problem is some lines of the subroutine are skipped when the value of the .date attribute is "N/A"

    .Date1 = mileEnd(CStr(program(j, 1)), "", timing) 
    .Date2 = mileEnd(CStr(program(j, 1)), "", timing)  
    .Date3 = mileEnd(CStr(program(j, 1)), "", timing) 
            
    .Date4 = mileStart(CStr(program(j, 1)), "", timing) 
    .Date5 = mileEnd(CStr(program(j, 1)), "", timing) 
    .Date6 = mileStart(CStr(program(j, 1)), "", timing) 
    .Date7 = mileEnd(CStr(program(j, 1)), "", timing) 

    If .date4 and .date5 is "n/a" then the .date6 and .date7 lines are skipped.

    Can anyone tell why this is happening?


    • Edited by becks23 Monday, June 15, 2015 11:57 AM
    Monday, June 15, 2015 11:17 AM

Answers

  • Hi all,

    I solved this .

    Just added a On Error Resume Next before each of the .Date.

    The error was because of the missing date values.

    Now it works fine.

    • Marked as answer by becks23 Monday, June 15, 2015 1:54 PM
    Monday, June 15, 2015 1:53 PM