2017-03-07 43 views
-2

在我的工作表「下載」中。在不同單元格中的單詞數量總結

在C列,我有:

BRONZE 
SILVER 
SILVER 
BRONZE 
GOLD 
PLATIN 
PLPLUS 
AMBASS 
PLPLUS 
etc... 

我想這樣做是

in the cell J7: Bronze: "Total of Bronze" 
in the cell J8: Silver: "Total of Silver" 
in the cell J9: Gold: "Total of Gold" 
in the cell J10:Platinum "Total of PLATIN" 
in the cell J11:Platinum Plus "Total of PLPLUS" 
in the cell J12:Ambassador "Total of AMBASS" 
in the cell J13:Total "Total of Bronze, silver, gold, platin, plplus & Ambass" 

我不認爲有人誰知道還有VBA這將是很難回答。

+0

'Countif()'和/或'Countifs()'? 「Total」是什麼意思,你要求什麼?你能澄清你想要做什麼,你已經嘗試過了嗎?這與「用戶體驗」有什麼關係? – BruceWayne

+0

@BruceWayne。首先我想我的問題很清楚。在C列我有不同的地位:青銅,銀,金等......然後我想要放在同一張紙上,但範圍J7是銅版紙的總數。我想在J7上寫上「青銅:」,然後與青銅細胞的數量...在J8相同,但與銀,J9與黃金等..和在J13所有人的總和 – JohanEs

+0

@BruceWayne,我把用戶體驗因爲我想你需要經驗才能找到解決方案...... – JohanEs

回答

1

Excel公式請嘗試對J1

="Total of " & COUNTIFS(C:C,C1) & " " & C1

+1

在excel公式中,我知道如何去做......但它是在vba上,這是更難... – JohanEs

+0

@JohanEs'ThisWorkbook.Worksheets(「Sheet1」)。Range(「J1」)。Formula =「= COUNTIFS(C:C,C2)」' – 0m3r

+1

我們如何把一個結果前的名字?它可以在Cell之前。例如:ThisWorkbook.Worksheets(「Sheet1」)。Range(「J7」)。Formula =「= COUNTIFS(C:C,」「BRONZE」「)」這會給我一個數字,但在這個結果的前面我想字銅牌或在此之前的單元格是I7 – JohanEs

1

我不知道你爲什麼在VBA這樣做,而是因爲你堅持它需要:

Sub CountThem 
    With Worksheets("Download") 
     .Range("J7").Value = "Bronze: " & Application.CountIf(.Range("C:C"), "Bronze") 
     .Range("J8").Value = "Silver: " & Application.CountIf(.Range("C:C"), "Silver") 
     .Range("J9").Value = "Gold: " & Application.CountIf(.Range("C:C"), "Gold") 
     .Range("J10").Value = "Platinum: " & Application.CountIf(.Range("C:C"), "PLATIN") 
     .Range("J11").Value = "Platinum Plus: " & Application.CountIf(.Range("C:C"), "PLPLUS") 
     .Range("J12").Value = "Ambassador: " & Application.CountIf(.Range("C:C"), "AMBASS") 
     .Range("J13").Value = "Total: " & _ 
           (Application.CountIf(.Range("C:C"), "Bronze") + _ 
           Application.CountIf(.Range("C:C"), "Silver") + _ 
           Application.CountIf(.Range("C:C"), "Gold") + _ 
           Application.CountIf(.Range("C:C"), "PLATIN") + _ 
           Application.CountIf(.Range("C:C"), "PLPLUS") + _ 
           Application.CountIf(.Range("C:C"), "AMBASS")) 

    End With 
End Sub 
+0

謝謝!我只是想出來,如何改變每個單元格的顏色,使其設計...大聲笑 – JohanEs

+0

@JohanEs記錄一個宏手動設置顏色。然後查看該代碼並查找它使用的顏色編號。然後修改我的答案中的代碼,通過添加額外的行來說諸如'.Range(「J7」)。Interior.Color = 49407'等。 – YowE3K

+0

如果我想改變字體顏色:我可以把:Sheets(「Download 「)。選擇 範圍(」J7:J14「).Cell.Font.Color = 2我不想讓複雜的東西變成白色的字體。 – JohanEs

相關問題