Click here to Skip to main content
14,868,503 members
Please Sign up or sign in to vote.
2.25/5 (4 votes)
See more:

My requirement is that I have to count the total number of row is used in excel // total number of word in excel // and total number of images in excel. Please, give me a sample code for all 3 requirement of excel.
its urgent
Updated 2-Sep-11 0:53am
Simon Bang Terkildsen 2-Sep-11 6:58am
"Please, give me a sample code for all 3 requirement" yeah that's going to happen.
Do some research and come back when you run into an issue.

1 solution

Hi A sample VBA code below may be help you.
Sub countRows()
    Dim lngRowsProject As Long
    lngRowsProject = Columns("AG:AG").SpecialCells(xlVisible).Rows.Count ' returns me 21 (column AH has 21 rows, but column AG has just 2)
    lngRowsProject = Range("AG").CurrentRegion.Rows.Count ' returns me 43 (the total numbers of rows in the spreadsheet are 43)
    MsgBox "The number of rows is " & lngRowsProject
End Sub

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900