Solved

Excel VBA Updating existing text label

Posted on 2007-03-26
3
177 Views
Last Modified: 2010-04-30
Hi all

I'm attempting to update a text label with a subtotal formula.  I'd like to do it without relying on VBA, but I'll take what I can get.  Subtotal will update anytime an autofilter criteria is changed, so I'd like to rely on that to change my label, but I can figure out how to do it outside a procedure, which follows:

Sub Calc_Subtotals()
'
    Application.ScreenUpdating = False

    With Sheet12.Subtotal_lbl
    .Caption = Range("D6").Text
    End With

    Application.ScreenUpdating = True
'
End Sub

Thanks for any suggestions!

-Scott
0
Comment
Question by:bfreescott
  • 2
3 Comments
 
LVL 80

Accepted Solution

by:
byundt earned 250 total points
ID: 18797721
Scott,
I assume that you want to change the caption on a command button or the like. If so, you can take advantage of the fact that the Calculate event sub runs whenever you use the AutoFilter and thereby change the value in a SUBTOTAL formula. Try the following sub in the codepane of the worksheet containing your AutoFilter.

Private Sub Worksheet_Calculate()
With Sheet12.Subtotal_lbl
      .Caption = Range("D6").Text
End With
End Sub

Brad
0
 

Author Comment

by:bfreescott
ID: 18798247
That did the trick!  Thanks Brad!
0
 
LVL 80

Expert Comment

by:byundt
ID: 18799249
Scott,
Thanks for the grade!
Brad
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Lately there has been a variety of news related to U.S. employment.  Stories about worker productivity, automobile and airline unions, low employment and foreign laborers have frequented the news.  Each story has good and bad attributes we might arg…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now