Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JCO JCO is offline
external usenet poster
 
Posts: 54
Default macro to control tabs (different worksheets)

If I already have a macro that accomplishes a task on Worksheet 1, how to I
cycle through the same macro to accomplish the same exact task on Worksheet
2 and Worksheet 3 of the same Workbook.

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default macro to control tabs (different worksheets)

If I already have a macro that accomplishes a task on Worksheet 1,
how to I cycle through the same macro to accomplish the same exact
task on Worksheet 2 and Worksheet 3 of the same Workbook.

Thanks


Please show your code.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion



---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
JCO JCO is offline
external usenet poster
 
Posts: 54
Default macro to control tabs (different worksheets)

Well the code is simple since I simple call the three sub routines shown
below:
So I want to call the same 3-routines for 3-worksheets in the same workbook

Sub FormatCharityTrackerReport()
RemoveComments&Columns
FormatReport
InsertHeader
End Sub

"GS" wrote in message ...
If I already have a macro that accomplishes a task on Worksheet 1, how
to I cycle through the same macro to accomplish the same exact task on
Worksheet 2 and Worksheet 3 of the same Workbook.

Thanks


Please show your code.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion



---
This email is free from viruses and malware because avast! Antivirus
protection is active.
http://www.avast.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default macro to control tabs (different worksheets)

Hi,

Am Sat, 9 Nov 2013 14:15:30 -0600 schrieb JCO:

Well the code is simple since I simple call the three sub routines shown
below:
So I want to call the same 3-routines for 3-worksheets in the same workbook

Sub FormatCharityTrackerReport()
RemoveComments&Columns
FormatReport
InsertHeader
End Sub


the important code is the code in your 3 procedures.
Into these procedures you have to change the code to:

For i = 1 to 3
With worksheet(i)
your code
end with
next

If you need more help please post the code of these 3 procedures


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #5   Report Post  
Posted to microsoft.public.excel.programming
JCO JCO is offline
external usenet poster
 
Posts: 54
Default macro to control tabs (different worksheets)

Ah! I gotch yak.
I was thinking I could encase the sub routines within the for loop, but now
I understand that I have to modify each of the routines. I have the info I
need, I believe.
Thanks

"Claus Busch" wrote in message
...
Hi,

Am Sat, 9 Nov 2013 14:15:30 -0600 schrieb JCO:

Well the code is simple since I simple call the three sub routines shown
below:
So I want to call the same 3-routines for 3-worksheets in the same
workbook

Sub FormatCharityTrackerReport()
RemoveComments&Columns
FormatReport
InsertHeader
End Sub


the important code is the code in your 3 procedures.
Into these procedures you have to change the code to:

For i = 1 to 3
With worksheet(i)
your code
end with
next

If you need more help please post the code of these 3 procedures


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2




  #6   Report Post  
Posted to microsoft.public.excel.programming
JCO JCO is offline
external usenet poster
 
Posts: 54
Default macro to control tabs (different worksheets)

I thought I had it but I'm not sure what is wrong. I think because I'm
using "ActiveSheet" which the sheet 2 and 3 never go active so this code is
not working.
Code:

'Add proper text as header
For i = 1 To 3
With Worksheets(i)
With ActiveSheet.PageSetup
.LeftHeader = sReportHeader 'left header as text
.RightHeader = sCurDate 'right header as text
End With
End With
Next



"Claus Busch" wrote in message ...

Hi,

Am Sat, 9 Nov 2013 14:15:30 -0600 schrieb JCO:

Well the code is simple since I simple call the three sub routines shown
below:
So I want to call the same 3-routines for 3-worksheets in the same
workbook

Sub FormatCharityTrackerReport()
RemoveComments&Columns
FormatReport
InsertHeader
End Sub


the important code is the code in your 3 procedures.
Into these procedures you have to change the code to:

For i = 1 to 3
With worksheet(i)
your code
end with
next

If you need more help please post the code of these 3 procedures


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2

  #7   Report Post  
Posted to microsoft.public.excel.programming
JCO JCO is offline
external usenet poster
 
Posts: 54
Default macro to control tabs (different worksheets)

Disregard this. I figured it out by simply using the code below:

Sub FormatCharityTrackerReport()
Dim i As Integer

Application.PrintCommunication = False
For i = 1 To 3 'work done on 3-sheets
Worksheets(i).Activate
FormatReport
DateHeader
Next
Application.PrintCommunication = True
Worksheets(1).Activate 'reset back to sheet 1
End Sub


"JCO" wrote in message ...

I thought I had it but I'm not sure what is wrong. I think because I'm
using "ActiveSheet" which the sheet 2 and 3 never go active so this code is
not working.
Code:

'Add proper text as header
For i = 1 To 3
With Worksheets(i)
With ActiveSheet.PageSetup
.LeftHeader = sReportHeader 'left header as text
.RightHeader = sCurDate 'right header as text
End With
End With
Next



"Claus Busch" wrote in message ...

Hi,

Am Sat, 9 Nov 2013 14:15:30 -0600 schrieb JCO:

Well the code is simple since I simple call the three sub routines shown
below:
So I want to call the same 3-routines for 3-worksheets in the same
workbook

Sub FormatCharityTrackerReport()
RemoveComments&Columns
FormatReport
InsertHeader
End Sub


the important code is the code in your 3 procedures.
Into these procedures you have to change the code to:

For i = 1 to 3
With worksheet(i)
your code
end with
next

If you need more help please post the code of these 3 procedures


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default macro to control tabs (different worksheets)

Hi,

Am Mon, 11 Nov 2013 17:38:51 -0600 schrieb JCO:

'Add proper text as header
For i = 1 To 3
With Worksheets(i)
With ActiveSheet.PageSetup
.LeftHeader = sReportHeader 'left header as text
.RightHeader = sCurDate 'right header as text
End With
End With
Next


you have to reference the PageSetup to the right sheets. Try:

For i = 1 To 3
With Worksheets(i)
With .PageSetup
.LeftHeader = sReportHeader 'left header as text
.RightHeader = sCurDate 'right header as text
End With
End With
Next


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #9   Report Post  
Posted to microsoft.public.excel.programming
JCO JCO is offline
external usenet poster
 
Posts: 54
Default macro to control tabs (different worksheets)

I knew it something like that.
Thanks

"Claus Busch" wrote in message ...

Hi,

Am Mon, 11 Nov 2013 17:38:51 -0600 schrieb JCO:

'Add proper text as header
For i = 1 To 3
With Worksheets(i)
With ActiveSheet.PageSetup
.LeftHeader = sReportHeader 'left header as text
.RightHeader = sCurDate 'right header as text
End With
End With
Next


you have to reference the PageSetup to the right sheets. Try:

For i = 1 To 3
With Worksheets(i)
With .PageSetup
.LeftHeader = sReportHeader 'left header as text
.RightHeader = sCurDate 'right header as text
End With
End With
Next


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tabs on excel worksheets Phyllis Excel Programming 2 April 6th 10 07:02 PM
Can I control entry into certain tabs? OrlaLynch Excel Discussion (Misc queries) 4 April 29th 08 06:24 PM
Worksheets Tabs ub Excel Worksheet Functions 10 April 9th 07 10:24 PM
Scroll bars without control tabs CJ Excel Worksheet Functions 3 August 23rd 06 12:55 AM
all tabs control home ch Excel Discussion (Misc queries) 1 March 17th 06 11:21 PM


All times are GMT +1. The time now is 07:25 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"