Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Excel VBA Updating existing text label

Posted on 2007-03-26
3
Medium Priority
?
196 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
[X]
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
  • 2
3 Comments
 
LVL 81

Accepted Solution

by:
byundt earned 1000 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 81

Expert Comment

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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

609 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