+ Reply to Thread
Results 1 to 12 of 12

Macro count items in sheet2 and provide count in embedded label in sheet1

  1. #1
    Forum Contributor
    Join Date
    04-23-2012
    Location
    Bradford PA
    MS-Off Ver
    Excel 2010
    Posts
    250

    Macro count items in sheet2 and provide count in embedded label in sheet1

    I am trying to create a simple count macro that will return the count to an embedded label on Sheet1.

    The count is essentially all Items (i.e cell that maintains a value) in column A of Sheet2 starting at Row8

    If there is none then count = 0

    I plan on incorporating this into my workbook open code.

    thanks for any help in advance.

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Macro count items in sheet2 and provide count in embedded label in sheet1

    Assuming you are using a form control label identified and "Label 1". This worked on a tested workbook.

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    04-23-2012
    Location
    Bradford PA
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: Macro count items in sheet2 and provide count in embedded label in sheet1

    Quote Originally Posted by stnkynts View Post
    Assuming you are using a form control label identified and "Label 1". This worked on a tested workbook.

    Please Login or Register  to view this content.
    Stnkynts,

    Thank you for the reply. I tried using the above code adjusted with specifics to my workbook. I have used a Label ActiveXcontrol from the developer tab.
    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Macro count items in sheet2 and provide count in embedded label in sheet1

    I have used a Label ActiveXcontrol from the developer tab.
    Which is why it did not work. Below will work for an ActiveX label

    Please Login or Register  to view this content.
    Last edited by stnkynts; 02-03-2015 at 06:32 PM.

  5. #5
    Forum Contributor
    Join Date
    04-23-2012
    Location
    Bradford PA
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: Macro count items in sheet2 and provide count in embedded label in sheet1

    Quote Originally Posted by stnkynts View Post
    Which is why it did not work. Below will work for an ActiveX label

    Please Login or Register  to view this content.
    Thanks for the reply. Unfortunately I was not able to get it to work with the change. I have even tried adding a new label without formatting at all and running it and still cant seem to get it to function. Any thoughts as to the problem?

  6. #6
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Macro count items in sheet2 and provide count in embedded label in sheet1

    Submit your workbook because both codes worked just fine for me when tested.

  7. #7
    Forum Contributor
    Join Date
    04-23-2012
    Location
    Bradford PA
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: Macro count items in sheet2 and provide count in embedded label in sheet1


  8. #8
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Macro count items in sheet2 and provide count in embedded label in sheet1

    It works just fine for me on your database. I run the code (independently of Workbook_Open) and a value of 3 is put into the Total Variances box under the "Database Summary" on the "Home" sheet. I don't know what is going wrong for you. Best of luck

  9. #9
    Forum Contributor
    Join Date
    04-23-2012
    Location
    Bradford PA
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: Macro count items in sheet2 and provide count in embedded label in sheet1

    Did you try operating it using the workbook open function...do you feel that is the problem?

  10. #10
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Macro count items in sheet2 and provide count in embedded label in sheet1

    Hmmm. There is some weird stuff going on with your sheet. After multiple testing, it would work, then I would close the sheet, open it back up, and it wouldn't work. In addition, your built in "Dashboard" macros to select the different sheets were on the fritz too. Sometimes they would work, sometimes the most simple single line of code would error for no reason. Sorry but I don't know what to tell you. Best of luck.

  11. #11
    Forum Contributor
    Join Date
    04-23-2012
    Location
    Bradford PA
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: Macro count items in sheet2 and provide count in embedded label in sheet1

    Stnkynts,

    I was able to get it to function as well today. Just randomly started working. I am not sure if you say the dashboard macros and this seem to have issues if it might have something to do surrounding "objects" in general and using macros on them.

    I am going to try running with it as it seems the code itself is accurate to get the desired results when it works. I would then like to inquire how I would make this structure conditional? In a sense to make the count the same but only count items with say "X" in column E and "PENDING" in column W? Would this require much modification as I can start a new thread if so.

  12. #12
    Forum Contributor
    Join Date
    04-23-2012
    Location
    Bradford PA
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: Macro count items in sheet2 and provide count in embedded label in sheet1

    Quote Originally Posted by stnkynts View Post
    Hmmm. There is some weird stuff going on with your sheet. After multiple testing, it would work, then I would close the sheet, open it back up, and it wouldn't work. In addition, your built in "Dashboard" macros to select the different sheets were on the fritz too. Sometimes they would work, sometimes the most simple single line of code would error for no reason. Sorry but I don't know what to tell you. Best of luck.
    Stnkynts,

    I was able to get it to function as well today. Just randomly started working. I am not sure if you say the dashboard macros and this seem to have issues if it might have something to do surrounding "objects" in general and using macros on them.

    I am going to try running with it as it seems the code itself is accurate to get the desired results when it works. I would then like to inquire how I would make this structure conditional? In a sense to make the count the same but only count items with say "X" in column E and "PENDING" in column W? Would this require much modification as I can start a new thread if so.

+ 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. Replies: 5
    Last Post: 09-29-2014, 11:08 AM
  2. [SOLVED] Macro to count the numbers of status in sheet1 against the dealer names of sheet2
    By Manish_Gupta in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-18-2014, 10:41 AM
  3. [SOLVED] Copy called out items from sheet1 to sheet2
    By MICowboy13 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-09-2014, 12:45 PM
  4. [SOLVED] Formula should count sheet1 and show in sheet2
    By [email protected] in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-07-2013, 04:57 AM
  5. How to count entries if sheet1 cell = sheet2 title
    By Melville in forum Excel General
    Replies: 3
    Last Post: 05-04-2010, 05:42 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