請問板上高手,有8個工作表,其中第2到第8個工作表,
如果要尋找
大股東合計1、大股東合計2、經理人合計、董監事合計之持股資料並累加至range("bb10"),如圖
(其中大股東合計1、大股東合計2、經理人合計、董監事合計之儲存格位置隨時都會變動,所以無法以sum去做累加)
只好用vba去抓資料:
程式碼如下
sub tes
for i=2 to 8
Sheets(i).Range("bb10") = Cells.Find(What:="大股東合計1", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, MatchByte:=False, SearchFormat:=False).Offset(, 3).Value + Cells.Find(What:="經理人合計", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, MatchByte:=False, SearchFormat:=False).Offset(, 3).Value + Cells.Find(What:="大股東合計2", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, MatchByte:=False, SearchFormat:=False).Offset(, 3).Value + Cells.Find(What:="董監事合計", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, MatchByte:=False, SearchFormat:=False).Offset(, 3).Value
Next
sub
但是卻出現錯誤,不知道錯在哪兒,能否請板上高手指點指點?謝謝 |