Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Excel VBA Updating existing text label

Posted on 2007-03-26
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!

Question by:bfreescott
  • 2
LVL 81

Accepted Solution

byundt earned 250 total points
ID: 18797721
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


Author Comment

ID: 18798247
That did the trick!  Thanks Brad!
LVL 81

Expert Comment

ID: 18799249
Thanks for the grade!

Featured Post

Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Limit the # times a macro code will run 14 50
Excel formula need currency format 1 23
EXCEL formula that pulls formatting as well 12 43
vba to flip column 14 17
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
The advancement in technology has been a great source of betterment and empowerment for the human race, Nevertheless, this is not to say that technology doesn’t have any problems. We are bombarded with constant distractions, whether as an overload o…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

808 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