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.

Apply code to other worksheets

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Metrazal - 23 Feb 2006 13:03 GMT
I have a master sheet that will have some additional sheets
modified at various times.  I want to have all my code saved in the
master sheet and applied to the other sheets from there.  For example:
I want to have the following code saved in the "master" sheet but
applied to "invoice"
sheet.

mytext = "ALMFG: AL MFG TAX"
For a = 1 To 999
If Cells(a, "c") = mytext Then Cells(a, "m") = Cells(a, "e")
Next a
mytext = "SHMFG: SHELBY CO MFG TAX"
For s = 1 To 999
If Cells(s, "c") = mytext Then Cells(s, "l") = Cells(s, "e")
Next s
mytext = "PEMFG: PELHAM MFG TAX"
For p = 1 To 999
If Cells(p, "c") = mytext Then Cells(p, "j") = Cells(p, "e")
Next p
mytext = "HEMFG: HELENA MFG TAX"
For h = 1 To 999
If Cells(h, "c") = mytext Then Cells(h, "k") = Cells(h, "e")
Next h

How can I achieve this?

Thanks,

Met

Signature

Metrazal

kikde - 23 Feb 2006 13:41 GMT
if you want to provie it in one workbook, put it in a global sub in the
workbook-code.
if you want to provide it for n workbooks, create an add-in

> I have a master sheet that will have some additional sheets
> modified at various times.  I want to have all my code saved in the
[quoted text clipped - 25 lines]
>
> Met
dbarelli - 23 Feb 2006 13:46 GMT
You only have to activate the desire worksheet, for example:

Sheets("invoice").activate

or if you want to activate by its codename:

sheet3.activate

rgds.

Signature

dbarelli

Metrazal - 23 Feb 2006 17:41 GMT
I could not get the Sheets("Sjournal").Activate to work.
Please explain how I would do an add-in or another method.

Thanks,

Met

Signature

Metrazal

kikde - 24 Feb 2006 06:57 GMT
sub test()
mytext = "ALMFG: AL MFG TAX"
For a = 1 To 999
 If ActiveWorkbook.Sheets.Cells(a, "c") = mytext Then
  ActiveWorkbook.Sheets.Cells(a, "m") = ActiveWorkbook.Sheets.Cells(a, "e")
end if
Next a
...
endsub

> I could not get the Sheets("Sjournal").Activate to work.
> Please explain how I would do an add-in or another method.
>
> Thanks,
>
> Met
 
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.