複製cog檔案的前兩列放至sheet1,複製整個gff檔案放至sheet2,sheet3為cog結果,sheet5為rna結果。即sheet1、sheet2為輸入資訊,sheet4為操作介面,sheet3、sheet5為輸出資訊。
vba巨集**如下(sheet4操作介面下):
private sub commandbutton1_click()
dim a, b as integer
a = textbox1.text
b = textbox2.text
'rna
dim m as integer
for j = 1 to b
if sheet2.cells(j, 3) = "trna" then
m = m + 1
end if
if sheet2.cells(j, 3) = "rrna" then
m = m + 1
end if
next
'sheet5.cells(1, 5) = m
for i = 1 to m
sheet5.cells(i, 1) = "genome"
next
dim n as integer
n = 1
for j = b - m + 1 to b
sheet5.cells(n, 2) = sheet2.cells(j, 3)
sheet5.cells(n, 3) = sheet2.cells(j, 4)
sheet5.cells(n, 4) = sheet2.cells(j, 5)
n = n + 1
next
'cog
for i = 1 to b
if sheet2.cells(i, 3) <> "gene" then
sheet2.rows(i).delete
end if
if sheet2.cells(i, 7) = "-" then
sheet2.cells(i, 6) = sheet2.cells(i, 5)
sheet2.cells(i, 5) = sheet2.cells(i, 4)
sheet2.cells(i, 4) = sheet2.cells(i, 6)
end if
next
sheet2.columns(8).delete
sheet2.columns(7).delete
sheet2.columns(6).delete
sheet2.columns(2).delete
sheet2.columns(1).delete
for i = 1 to a
sheet3.cells(i, 1) = sheet1.cells(i, 1)
sheet3.cells(i, 4) = sheet1.cells(i, 2)
next
for j = 1 to b
sheet2.cells(j, 4).replace what:="locus_tag=", replacement:=""
next
'for j = 1 to b
' if len(sheet2.cells(j, 4)) = 12 then
' sheet2.cells(j, 4) = left(sheet2.cells(j, 4), 11) + "0000" + right(sheet2.cells(j, 4), 1)
' end if
' if len(sheet2.cells(j, 4)) = 13 then
' sheet2.cells(j, 4) = left(sheet2.cells(j, 4), 11) + "000" + right(sheet2.cells(j, 4), 2)
' end if
' if len(sheet2.cells(j, 4)) = 14 then
' sheet2.cells(j, 4) = left(sheet2.cells(j, 4), 11) + "00" + right(sheet2.cells(j, 4), 3)
' end if
' if len(sheet2.cells(j, 4)) = 15 then
' sheet2.cells(j, 4) = left(sheet2.cells(j, 4), 11) + "0" + right(sheet2.cells(j, 4), 4)
' end if
'next
for i = 1 to a
for j = 1 to b
if sheet3.cells(i, 1) = sheet2.cells(j, 4) then
sheet3.cells(i, 2) = sheet2.cells(j, 2)
sheet3.cells(i, 3) = sheet2.cells(j, 3)
end if
next
next
'for j = 1 to b
' sheet4.cells(j, 12) = right(sheet2.cells(j, 4), 15)
'next
for i = 1 to a
if sheet3.cells(i, 4) = "" then
sheet3.cells(i, 4) = 0
end if
next
end sub
輸入歌手獲得歌曲並寫入檔案
coding utf 8 import requests import json import os while true name input 請輸入歌曲名稱 if not name.strip break if not os.path.exists name.txt with open name...
VBA讀取檔案
首先我們需要認識幾個相關定義 filesystemobject 檔案系統定義 set fs createobject scripting.filesystemobject set a fs.createtextfile c testfile.txt true a.writeline this is ...
VBA 選擇檔案
option explicit sub 開啟檔案 dim filenameobj as variant dim afile as variant 陣列,提取檔名filename時使用 開啟檔案對話方塊返回的檔名,是乙個全路徑檔名,其值也可能是false,因此型別為variant dim filena...