使用EXCEL宏,VBA,找出整个sheet1中的所有绿色单元格,并读取每个单元格的值

2025-04-05 03:54:13
推荐回答(1个)
回答1:

sub test()
dim jgarr(1 to 1000) as string
dim jgJs as integer
for each mycell in sheets(“sheet1”).cells
if mycell.font.color=? then '?绿色的色号 自己查一下
jgjs=jgjs+1
jgarr(jgjs)=mycell.text
endif
next mycell
'输出结果
sheets("sheet2").activate
for i=1 to jgjs
cells(i,1)=jgarr(i)
next i
end sub
随手写了一下,没有调试过