如何用VBA編寫,把工作表中相同字串標記上顏色,非常感謝

時間 2021-08-11 18:14:10

1樓:姓王的

dim i&, j&, n%, b%, ra as rangeset ra = activesheet.usedrangera.font.

colorindex = -4105n = 3

for i = 1 to ra.count - 1b = 0

if n > 18 then n = 3

a = ra(i).font.colorindexif ra(i).font.colorindex = -4105 and not isempty(ra(i)) then

for j = i + 1 to ra.countif ra(i) = ra(j) then ra(j).font.colorindex = n: b = 1

next

if b = 1 then ra(i).font.colorindex = n: n = n + 1

end if

next

**執行後效果如下圖。

2樓:匿名使用者

條件格式就行了,用不著vba

vba程式設計合併一列excel資料(幾萬條)中字元相同的行,比較急!感謝!

3樓:慶年工坊

sub ***()

x = 2

n = 1

do while cells(x, 3) <> ""

a = x

do until cells(a, 3) <> cells(x, 3)

a = a + 1

loop

if a <> x + 1 then range(cells(x, 4), cells(a - 1, 4)).mergecells = true

cells(x, 4).horizontalalignment = xlcenter

cells(x, 4) = n

n = n + 1

x = a

loop

end sub

4樓:匿名使用者

哇,這麼多金幣?!我來幫你!

excel表中如何用簡單的公式把多個工作表不同單元格的資料相

紫色魚魚 呵呵,能想到的都被你說了。我個人覺得用多重合並資料透視最簡單。excel中如何把不同 中的資料求和? 演示excel怎麼快速對兩個 疊加求和 第一步 開啟excel軟體,隨便輸入資料,第二步,在空白區域計算張三和趙五的年齡和,公式 sumif a2 a6,張三 b2 b6 sumif a2...

excel中如何編寫vba判斷迴圈多行單元格數值及賦值

太極健 你的判斷是為0而不是為空,如果是判斷為空,迴圈如下 sub test i range a65536 end xlup row 判斷a列最後一行的行號 for x 1 to i 建立迴圈從第一行到最後一行if cells x,1 0 then cells x,6 cells x,1 cells...

Excel如何用VBA實現表資料格式轉換

這個實現起來不難,主要是程式的控制,試試下面的 sub zz dim ar,a b n t a array 3,7,11 b array 6,10,15 ar sheets 1 a1 currentregion.value redim c 1 to ubound ar 1 ubound b 2 1 ...