Markets traded range bound and ended marginally higher amid weak global cues on Tuesday. The BSE Sensex ended at 40,544.37, up 112.77 points or 0.28%. The Nifty was at 11,896.80, up 23.75 points or 0.20%.