原創: 牛超
2009-06
osaka
如題,修改原來的指令碼,引用usedrange
private sub fillvalueauto(astr as string, currow as long)
dim svalue as string
dim sbatname as string
dim spgid as string
dim sbatnamew as string
dim i as long
astr = trim(lcase(astr))
'msgbox str(thisworkbook.worksheets(1).cells.rows.count)
for i = 1 to thisworkbook.worksheets(1).usedrange.rows.count
svalue = thisworkbook.worksheets(1).usedrange.cells(i, 1)
svalue = trim(lcase(svalue))
if len(trim(svalue)) = 0 then
goto con
end if
if astr = svalue then
sbatname = trim(thisworkbook.worksheets(1).usedrange.cells(i, 1))
spgid = trim(thisworkbook.worksheets(1).usedrange.cells(i, 3))
spgidw = trim(activesheet.usedrange.cells(currow, 8))
activesheet.usedrange.cells(currow, 11) = spgid
if not lcase(spgidw) = lcase(spgid) then
activesheet.usedrange.cells(currow, 12) = "*"
end if
exit for
end if
con:
next
if not astr = svalue then
activesheet.usedrange.cells(currow, 13) = "xx"
end if
end sub
private sub commandbutton1_click()
dim strget as string
dim strret as string
dim itmp as integer
dim i as integer
dim flag as boolean
dim mindex as long
'for mindex = 1 to 600
' strget = activesheet.cells(mindex, 6)
for mindex = 1 to activesheet.usedrange.rows.count
strget = activesheet.usedrange.cells(mindex, 6)
if len(trim(strget)) = 0 then
goto con
end if
if instr(strget, ".bat") then
fillvalueauto strget, mindex
end if
'textbox1.text = textbox1.text & str(mindex) & chr(13) & chr(10)
con:
next
end sub
Excel中使用VBA訪問Access資料庫
excel中使用vba的優點 巨集是vba的一種簡單應用。巨集可以通過編寫vba 錄製巨集兩種方式獲得。通常是先錄製巨集,再在獲得的巨集的基礎上進行語句優化調整,最後得到想要的巨集。在 誰說菜鳥不會資料分析 工具篇 第四章 讓報告自動化中,涉及到根據輸入日期,從access資料庫中提取相關資料到ex...
excel中使用VBA將單元格的內容轉為多行
功能實現 將sheet1中a1單元格的值拆分後 顯示到sheet2的a列中 private sub worksheet change byval target as range 只有a1單元格的值改變才會執行 if target.address a 1 then 定義變數 dim x as inte...
Excel中使用VBA進行度分秒與十進位制度的轉換
發現excel的vba功能真是批量處理的一把利刃,工作中小試牛刀了一把,將excel中度分秒形式的座標批量處理成十進位制度形式,處理完後用於gis展點製圖。原excel資料如下 vba 如下 1 subcoorder 2dim longitude,latitude as string arr 3di...