+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    02-06-2007
    Posts
    3

    macro question and count question... thanks!

    Thanks for looking.

    Question 1:
    I have a spreadsheet that I use the auto format function on. When I search one of the columns that has text to display only records that are "complete" for example, those records are displayed, but the row numbers jump around and I need to figure out the easiest way to count the number of records with a certain status.

    Currently, I am inserting a column and putting a 1 next to each record and using the sum function.

    Is there an easier way?

    Question 2:
    I have an access DB that generates a spreadsheet for me and I would like to have a macro available that does some simple formatting for me.

    I have figured out how to make a macro, but it only seems to work when I am using the file I created the macro in.

    When my DB generates the next excel report, the macro is no longer available.

    Any thoughts?

    Thanks very much for your time.

  2. #2
    Forum Moderator Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2007
    Posts
    5,212
    Regarding counting the number of occurrences of a value in a column, you should be able to use the COUNTIF(range,criteria) function. For example:

    A1 through A5 contain: Complete, No, No, Complete, Complete
    A6 has the formula: =COUNTIF(A1:A5,"Complete")
    Result in A6 should be: 3

    ------------------------------------------

    Regarding question 2, if you save the Macro in your personal macro folder, it should be available at any time. When creating a macro you can specify it's name, shortcut key, storage location ("Store macro in:") and description. For the 'Store Macro In' drop-down box, choose 'Personal Macro Workbook'. You should then be able to go into any Excel workbook and choose Tools>Macros... and see your macro listed there.

  3. #3
    Valued Forum Contributor
    Join Date
    07-13-2006
    Posts
    400
    question 1: =countif(range,criteria)
    i.e. countif(A1:A100,1) will count the occurences of 1 in A1 to A100

    question 2: try adding the macro to your personal.xls
    This is your personal collection of macros that is automatically opened and running with excel. When recording a macro choose "Store Macro in:" and choose Personal.xls

    hth

    *EDIT* pjoaquin beat me by a couple seconds
    --Mark

    Quantum materiae materietur marmota monax si marmota monax materiam possit materiari?

  4. #4
    Forum Guru VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    12,009
    Hi,

    Try a countif function e.g

    =COUNTIF(B:IV,"a")

    This counts all the letter a's from Col B to IV

    You could add the macro to your personal macro's.
    When you recorded the macro before you tick ok select personal macro workbook from the drop down

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  5. #5
    Registered User
    Join Date
    02-06-2007
    Posts
    3

    Thanks very much. Here's what worked.

    The "countif" function did work, but because I was counting text, I had to put Quotes around the text first.

    Thanks very much for the help

  6. #6
    Forum Guru VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    12,009
    Glad you got a Solution

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0