Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / February 2006

Tip: Looking for answers? Try searching our database.

New to macros, need to update worksheets

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tina - 28 Feb 2006 14:31 GMT
I've just learned how to do macros in a class and am hoping to apply it to
something at work.

We have a workbook (with MANY spreadsheets) that reflect billing.  The main
sheet is updated each month - Column H has January info and Column I will
have Feb info.

Then there are sheets for each program.  Each sheet has some numerical data
and a chart.  After January's information was entered, the data on each sheet
was manually changed to refer to column H.  Once Feb's info is entered, it
will manually be changed to refer to column I (the new data).  Is this
something that can be automated with a macro??

Bear with me because this is to new to me, but I know there has to be a
better way to handle this workbook.
Ed - 28 Feb 2006 15:30 GMT
-- Are all the sheets except for the main sheet to be updated?
-- Is it the same cells in each program sheet that need to be updated?
-- How would you identify which cells on the main sheet contain the updated
data for each specific program?

Ed

> I've just learned how to do macros in a class and am hoping to apply it to
> something at work.
[quoted text clipped - 11 lines]
> Bear with me because this is to new to me, but I know there has to be a
> better way to handle this workbook.
Tina - 28 Feb 2006 15:56 GMT
see below - thanks

> -- Are all the sheets except for the main sheet to be updated? YES
> -- Is it the same cells in each program sheet that need to be updated? YES
[quoted text clipped - 21 lines]
> > Bear with me because this is to new to me, but I know there has to be a
> > better way to handle this workbook.
Ed - 28 Feb 2006 17:09 GMT
> > -- How would you identify which cells on the main sheet contain the updated
> > data for each specific program?  I DON'T KNOW - I'm honestly not sure how to go about this...

What I mean is: when you look at the main sheet, how do you know which data
cells go with which program?  For instance, is the program name listed down
Column A, and the data for that program is in H of the same row?  How many
cells need to be updated from the main sheet, and how do you know which ones
they are?

The biggest thing to remember about any routine like this is that it can
almost always be broken into smaller increments.  When you take it one step
at a time, it's not so very intimidating.  You do have to be able to
identify the process you would use without a macro, because your macro is
going to have to do that same process. And what we know intuitively when we
look at our work has to be spelled out in detail for in the code.

Try this:
-- Create a new Excel workbook and give it some more worksheets.
-- Put the macro below into a module.  (With Excel open, press ALT+F11 -
this opens the Visual Basic Editor (VBE).  Go to Insert >> Module.  Copy
everything below from "Sub UpdateAllSheets()" to "End Sub".)
-- Back in Excel, press ALT+F8 to bring up a list of macros.  Choose
"UpdateAllSheets" and see what happens.  (The macro sets the Zoom percentage
for every sheet except Sheet1.)
-- Go back to the VBE and look at the code, and see if you can understand
what the code is doing.

Ed

Sub UpdateAllSheets()

Dim objWkbk As Workbook
Dim objWksh As Worksheet
Dim strZm As String
Dim intZm As Integer

Set objWkbk = ActiveWorkbook

strZm = InputBox("What zoom?")
If strZm = "" Then GoTo ExitHere

intZm = strZm

For Each objWksh In objWkbk.Sheets
 If objWksh.Name <> "Sheet1" Then
   objWksh.Activate
   ActiveWindow.Zoom = intZm
   objWksh.Range("A1").Select
 End If
Next objWksh

objWkbk.Sheets("Sheet1").Activate

ExitHere:
End Sub

> see below - thanks
>
[quoted text clipped - 23 lines]
> > > Bear with me because this is to new to me, but I know there has to be a
> > > better way to handle this workbook.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.