VBA procedure to update worksheets...

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""

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


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

ronadairAuthor Commented:
Can this code be altered so that every worksheet with the character " > " (or some other character) in its name was updated as above?
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ronadairAuthor Commented:
Works like a charm!

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.