1. 獲取表頭的列號,可直接調用函數,傳入參數,因為是表頭,所以rowID為 1
2. 獲取第一列中行表頭的所在行,傳入參數時,colID 為 1
'獲取列號 Public Function Find_Col_ID(ByVal rowID, ByVal objWorkBook, ByVal objWorkSheet, ByVal strColName) As Integer objWorkBook.Activate objWorkSheet.Select objWorkSheet.Cells(1, 1).Select Cells.Find(what:=strColName, after:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Select If Selection.Row = rowID Then Find_Col_ID = Selection.Column Else Find_Col_ID = 0 End If End Function '獲取行號 Public Function Find_Row_ID(ByVal colID, ByVal objWorkBook, ByVal objWorkSheet, ByVal strName) As Integer objWorkBook.Activate objWorkSheet.Select objWorkSheet.Cells(1, 1).Select Cells.Find(what:=strName, after:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Select If Selection.Columns = colID Then Find_Row_ID = Selection.Rows Else Find_Row_ID = 0 End If End Function