+ Reply to Thread
Results 1 to 3 of 3

How to count cells that begin with certain letter or characters

  1. #1
    Registered User
    Join Date
    10-26-2015
    Location
    JC, TN
    MS-Off Ver
    Office 365 for Enterprise version 2208
    Posts
    41

    How to count cells that begin with certain letter or characters

    Yes, I'm still quite the novice at VBA and such but I'm learning.....albeit, slowly. I'm rebuilding an old inventory sheet for individuals in my company to use to keep their inventories more accurate. It breaks down each user's inventory into alphabetical groups. The whole sheet works as it should now. I'm just trying to tweak it a little to make it better and these tweaks are giving me a headache.
    On the INSTRUCTIONS sheet, after they've imported their inventory using the step 1, 2, and 3 buttons, I would like for them to be able to see how many items there are to be counted in each alphabetic grouping before they start that group. I added a button to do that, but I can't get any code to work. I even tried using ChatGPT for an hour or so and it kept failing as well. What seems to be making this so difficult is that there are some Item Descriptions that don't begin with a letter at all. Some begin with a number or special character (almost always an open parenthesis).
    If I can ever get some code to work correctly, I would like to do away with the new button that runs that "totaling" macro and integrate the code at the end of the code used when the Step 3 button is clicked.

    It's a Monday and I seem to be giving information that isn't pertinent to my problem so here we go:
    I need code that will go to the INVENTORY sheet, column D, and count the rows that begin with each number, special character, or letter. Then, report those totals back to the INSTRUCTIONS sheet in cells J24 thru J31 to total those letter groupings shown there. NOTE that the A to B group will also include those items beginning with a number or special character.
    The way I've been trying to do this is to report the individual totals to column Z and then use a formula in the appropriate letter grouping to simply sum up the totals. Example: cell J24 is for those items beginning with numbers, spec characters, A, and B. So my formula would simply take what the macro puts in column Z for the total rows beginning with A, B, (, and any number and show that total in J24.
    My problem is that I can't get any code I've tried to work and actually total the alphabet groups individually. It either does pretty much nothing or bugs. The code I got from ChatGPT was a new approach I hadn't tried and it errors near the end with an Object variable or With block variable error. That code is below:
    Please Login or Register  to view this content.
    I'm open to any approach that will work at this point. If we can use this code, fine. If there's a better way of doing it other than my column Z thought process, I'm good with that too. At this point, I would just like for something that works.
    Thank you for your time and any help you can offer!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    2,097

    Re: How to count cells that begin with certain letter or characters

    Does this work for you?

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    10-26-2015
    Location
    JC, TN
    MS-Off Ver
    Office 365 for Enterprise version 2208
    Posts
    41

    Re: How to count cells that begin with certain letter or characters

    That worked. Thank you for the quick work.
    Glancing at this, it would take me a few days to figure out how to split the results because I'm not following this code. So, can the results be separated with the letter/no letter being in the Y column and the results being in the corresponding Z column? Then I can put a formula in to reference the numbers in the Z column for the totals.

    UPDATE: Nevermind. I slowed down and really looked at what you gave me and have it edited to put the group in column Y and the count in Z. This thread has been solved. Thank you!

    I have to say that it really bugs me when you guys show me exactly how much I simply don't know yet!
    Last edited by possumbarnes; 03-13-2023 at 03:18 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. LEN function to count just letter characters
    By Excelnewbie7 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-30-2021, 04:48 AM
  2. Identify Cells/Data that begin with 3 characters and a -
    By mnfez in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-01-2015, 09:35 AM
  3. Filter names that begin with certain letter
    By enphynity in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-28-2012, 11:51 AM
  4. How to Subtotal values that begin with a letter?
    By sstendahl in forum Excel General
    Replies: 3
    Last Post: 04-25-2012, 10:31 PM
  5. Count individual letters or letter combos w/in cells that contain other characters
    By superupsman in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-14-2011, 02:23 PM
  6. count cells that begin with specific text
    By mmer at steelcase in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 07-25-2006, 04:05 PM
  7. Replies: 5
    Last Post: 06-08-2006, 12:10 PM

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.6.0 RC 1