新足迹

 找回密码
 注册

精华好帖回顾

· Box Hill的银行 (2005-10-5) goldenapple · 绚丽日出--Kiama 10P (2013-5-22) Wolongshan
· 私立肿瘤医生的日常之小说版 (2019-5-26) ThePlaceToBe · 谈谈我在小公司做会计的工作经历(firm) (2012-6-2) KatnissEverdeen
Advertisement
Advertisement
查看: 1192|回复: 18

[其他] Can you do word count in Excel? [复制链接]

发表于 2010-8-9 10:32 |显示全部楼层
此文章由 猪猪的宝贝 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 猪猪的宝贝 所有!转贴必须注明作者、出处和本声明,并保持内容完整
If you can, how do you do it???

thanks!!
Advertisement
Advertisement

退役斑竹

发表于 2010-8-9 10:44 |显示全部楼层
此文章由 garysu 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 garysu 所有!转贴必须注明作者、出处和本声明,并保持内容完整

发表于 2010-8-9 11:10 |显示全部楼层
此文章由 猪猪的宝贝 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 猪猪的宝贝 所有!转贴必须注明作者、出处和本声明,并保持内容完整
thanks LS, but I dont understand... kan bu dong...




Word Count

   
         Unlike MS Word, Excel doesn't have a built in method for counting the number of words in a spreadsheet. However, you can count the number of words with a simple VBA macro.

  

Sub CountWords()
    Dim WordCount As Long
    Dim Rng As Range
    Dim S As String
    Dim N As Long
    For Each Rng In ActiveSheet.UsedRange.Cells
        S = Application.WorksheetFunction.Trim(Rng.Text)
        N = 0
        If S <> vbNullString Then
            N = Len(S) - Len(Replace(S, " ", "")) + 1
        End If
        WordCount = WordCount + N
    Next Rng
    MsgBox "Words In ActiveSheet Sheet: " & Format(WordCount,"#,##0")
End Sub


  To count the words in a single cell, you can use the following formula:
=IF(LEN(A1)=0,0,LEN(TRIM(A1))-LEN(SUBSTITUTE(TRIM(A1)," ",""))+1)

This works by first using TRIM to convert multiple spaces to single spaces and remove any leading or trailing spaces. Then it subtracts from the Length of A1 the Length of  A1 after all spaces have been removed (SUBSTITUE).  The difference is the number of spaces in A1. Add 1 to that and you get the number of words. The same function in VBA is shown below. Note that it uses Excel's worksheet function TRIM, not VBA's Trim function. The two are not the same. Both functions remove leading and trailing spaces, but Excel's TRIM changes multiple spaces within the string to single spaces, while VBA's Trim function leaves multiple spaces within the string intact. For example,

Debug.Print Application.WorksheetFunction.Trim("   a   b   c   ")
prints
a b c
while
Debug.Print Trim("   a   b   c   ")
prints
a   b   c

Function WordsInCell(Cell As Range) As Variant
    If Cell.Cells.Count <> 1 Then
        '''''''''''''''''''''''''''''''''''
        ' return #VALUE if there is more
        ' than one cell referenced by Cell.
        '''''''''''''''''''''''''''''''''''
        WordsInCell = CVErr(xlErrValue)
        Exit Function
    End If
    If Len(Cell.Text) > 0 Then
        With Application.WorksheetFunction
            WordsInCell = Len(.Trim(Cell.Text)) - _
                Len(.Substitute(.Trim(Cell), " ", "")) + 1
        End With
    Else
        WordsInCell = 0
    End If
End Function
你被捧上天,你被批评得一无是处,只要看到你踢球时熟悉的样子,我就知道你依然是你。

发表于 2010-8-9 12:29 |显示全部楼层

回复 3# 的帖子

此文章由 kaixin123 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 kaixin123 所有!转贴必须注明作者、出处和本声明,并保持内容完整
I just copy and post to word to count the words.

发表于 2010-8-9 12:50 |显示全部楼层

回复 4# 的帖子

此文章由 猪猪的宝贝 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 猪猪的宝贝 所有!转贴必须注明作者、出处和本声明,并保持内容完整
good idea!

i was counting one by one, almost dead.

发表于 2010-8-9 12:54 |显示全部楼层
此文章由 leoqy 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 leoqy 所有!转贴必须注明作者、出处和本声明,并保持内容完整
原帖由 猪猪的宝贝 于 2010-8-9 11:50 发表
good idea!

i was counting one by one, almost dead.

Advertisement
Advertisement

发表于 2010-8-9 14:23 |显示全部楼层
此文章由 dongdou 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 dongdou 所有!转贴必须注明作者、出处和本声明,并保持内容完整
Hey babypig - are u doing this for project Pt B?
No word count is required for Pt B.

发表于 2010-8-9 14:31 |显示全部楼层

回复 7# 的帖子

此文章由 猪猪的宝贝 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 猪猪的宝贝 所有!转贴必须注明作者、出处和本声明,并保持内容完整
hey thanks for asking.

I was doing Part A with Excel, but read the requirement again and realised you have to do Part A in either work of PDF.

So I am now transferring everything into Word from Excel now
你被捧上天,你被批评得一无是处,只要看到你踢球时熟悉的样子,我就知道你依然是你。

发表于 2010-8-9 18:06 |显示全部楼层

回复 8# 的帖子

此文章由 dongdou 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 dongdou 所有!转贴必须注明作者、出处和本声明,并保持内容完整
No worries.

But make sure you upload  Pt B in Excel format.

Good luck

发表于 2010-8-9 18:41 |显示全部楼层
此文章由 miaom 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 miaom 所有!转贴必须注明作者、出处和本声明,并保持内容完整
原帖由 dongdou 于 2010-8-9 13:23 发表
Hey babypig - are u doing this for project Pt B?
No word count is required for Pt B.


babypig.....听起来像sukling pig
头像被屏蔽

禁止访问

发表于 2010-8-9 23:22 |显示全部楼层
此文章由 ah123 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 ah123 所有!转贴必须注明作者、出处和本声明,并保持内容完整
猪猪加油!猪猪加油!
Advertisement
Advertisement

发表于 2010-8-10 11:33 |显示全部楼层
此文章由 kaixin123 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 kaixin123 所有!转贴必须注明作者、出处和本声明,并保持内容完整
原帖由 dongdou 于 2010-8-9 17:06 发表
No worries.

But make sure you upload  Pt B in Excel format.

Good luck

are you sure in excel format? i submit the PDF for part B........

发表于 2010-8-10 11:33 |显示全部楼层
此文章由 kaixin123 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 kaixin123 所有!转贴必须注明作者、出处和本声明,并保持内容完整
原帖由 猪猪的宝贝 于 2010-8-9 11:50 发表
good idea!

i was counting one by one, almost dead.

you such a lovely pig  

发表于 2010-8-10 13:04 |显示全部楼层
此文章由 猪猪的宝贝 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 猪猪的宝贝 所有!转贴必须注明作者、出处和本声明,并保持内容完整
原帖由 kaixin123 于 2010-8-10 10:33 发表

are you sure in excel format? i submit the PDF for part B........

hmmm..
go and read the project guide again.
i am pretty sure it stated to submit part A in word or PDF and part b with the provided template (which is excel)

but i guess as long as your figures are shown, and since they are marking on the hard copy, it should be fine as they can't tell the formula on hard copy anyway
你被捧上天,你被批评得一无是处,只要看到你踢球时熟悉的样子,我就知道你依然是你。

发表于 2010-8-10 13:10 |显示全部楼层

回复 14# 的帖子

此文章由 kaixin123 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 kaixin123 所有!转贴必须注明作者、出处和本声明,并保持内容完整
yes, they say it is fine...
差点杯具了

评分

参与人数 1积分 +2 收起 理由
猪猪的宝贝 + 2 安慰一下

查看全部评分

发表于 2010-8-10 13:13 |显示全部楼层

回复 15# 的帖子

此文章由 猪猪的宝贝 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 猪猪的宝贝 所有!转贴必须注明作者、出处和本声明,并保持内容完整
that's good:)

i just feel so relaxed after submited it yesterday, i havent started unit 3, really need to get it going!
Advertisement
Advertisement

发表于 2010-8-10 13:17 |显示全部楼层
此文章由 kaixin123 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 kaixin123 所有!转贴必须注明作者、出处和本声明,并保持内容完整
me too. it is like finish the whole course.........
anyway, straight away my mind tell me to start unit 3 which we already left behind the schedule. but too lazy last night to study unit 3...had a good sleep last night.....
加油!

[ 本帖最后由 kaixin123 于 2010-8-10 12:18 编辑 ]

发表于 2010-8-10 13:26 |显示全部楼层

回复 17# 的帖子

此文章由 猪猪的宝贝 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 猪猪的宝贝 所有!转贴必须注明作者、出处和本声明,并保持内容完整
same here! i guess thats wat happened to most ppl. lol

发表于 2010-8-10 13:58 |显示全部楼层

回复 18# 的帖子

此文章由 kaixin123 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 kaixin123 所有!转贴必须注明作者、出处和本声明,并保持内容完整
continuing tonight (paopaobing(13))

发表回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Advertisement
Advertisement
返回顶部