excel - How to copy information into a column corresponding to what is found in another column? -


i have wrote macro want copy path location saved email , attachments column b, when no .csv file found. here code below:

dim csv_ap string dim path_report string  sheets("mail report").activate csv_ap = range("c65000").end(xlup).value  if csv_ap = "no"     path_report = main_path & "for resolution\" & format(today, "dd_mm_yy") & "manual_handling_" & range("a65000").end(xlup).value      range("b65000").end(xlup).offset(1).value = path_report  end if 

here resulting spreadsheet after macro has run. can see paths not aligned "no"s in column c. need macro realize paths need aligned correct row. how can this? (the picture below example in different in other cases)

screenshot result of macro (range(b1:b2) empty before macro)

there many different (and possibly better) ways approach this, making minimal change existing code this:

dim csv_ap range dim path_report string  sheets("mail report").activate set csv_ap = range("c65000").end(xlup)  if csv_ap.value = "no"     path_report = main_path & "for resolution\" & format(today, "dd_mm_yy") & "manual_handling_" & range("a65000").end(xlup).value      csv_ap.offset(0, -1) = path_report  end if 

instead of returning string csv_ap, returns range. tests value of cell , if equals "no" returns path report cell left.


Comments