1. 程式人生 > >vba呼叫javascript函式封裝

vba呼叫javascript函式封裝

//返回單元格值
function getValue(sheet, row, col) {
	if(col==undefined) {
		return sheet.range(row).value;
	} else {
		return sheet.cells(row, col).value;
	}
}

//設定單元格值
function setValue(sheet, value, row, col) {
	if(col==undefined) {
		sheet.range(row).value = value;
	} else {
		sheet.cells(row, col).value = value;
	}
}


//過濾
function filter(sheet, rangeStr, col, value) {
	sheet.range(rangeStr).AutoFilter(col, value);
}

//取消過濾
function filterCancel(sheet, rangeStr) {
	sheet.range(rangeStr).AutoFilter;
}
//排序 1:升序;2:降序
function sort(sheet, sectionRangeStr, byRangeStr, order){
	order = order===undefined ? 1 : order;
	sheet.range(sectionRangeStr).sort(sheet.range(byRangeStr+"1"), order);
}