?
Solved

VBA procedure to update worksheets...

Posted on 2008-11-11
4
Medium Priority
?
404 Views
Last Modified: 2012-06-27
I would like to update formulas & text in worksheets.  What is the VBA procedure that will do it?  Let's say:
1)  the worksheet to be updated is open
2)  the formula is "A1 = B1"
3)  the text is "C1 = "NewText""

Thanks.
0
Comment
Question by:ronadair
  • 2
  • 2
4 Comments
 
LVL 1

Expert Comment

by:lewismay
ID: 22958805
Hello,

Paste the following code into the worksheet code area (Alt F11) and it will run every time the worksheet is activated.

Hope this helps
Private Sub Worksheet_Activate()
 
    Application.ActiveSheet.Range("A1").Formula = "=B1"
    Application.ActiveSheet.Range("C1").Value = "NewText"
 
End Sub

Open in new window

0
 

Author Comment

by:ronadair
ID: 22960603
Can this code be altered so that every worksheet with the character " > " (or some other character) in its name was updated as above?
0
 
LVL 1

Accepted Solution

by:
lewismay earned 2000 total points
ID: 22975085
Yep try something like this
Private Sub Worksheet_Activate()
 
    Dim sheet, key
    
    key = ">"
    
    For Each sheet In Application.Worksheets
 
        If InStr(sheet.Name, key) Then
        
            sheet.Range("A1").Formula = "=B1"
            sheet.Range("C1").Value = "NewText"
            
        End If
        
    Next sheet
 
End Sub

Open in new window

0
 

Author Closing Comment

by:ronadair
ID: 31515500
Works like a charm!

Thanks.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month13 days, 15 hours left to enroll

807 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