2017-03-07 62 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

相关问题