Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Programming a new macro

I have a macro that automatically controls the format of cells in a worksheet.
Example:
Sheet1
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then Range("A1").EntireColumn.AutoFit
End Sub


Now I want make a macro that insert a new worksheet and the loads this
automatic macro into the new worksheet. Is this possible?

BR
Trond
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Programming a new macro

Save the workbook with the code as a template and then when you require a
new workbook open the template, this will create a new workbook (with the
code) and rename the workbook sequentially e.g. if you called the template
MyCodeBook then when you open the template the new workbook will be named
MyCodeBook1, the next one MyCodeBook2 etc....


--
Cheers
Nigel



"Trond" wrote in message
...
I have a macro that automatically controls the format of cells in a

worksheet.
Example:
Sheet1
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then Range("A1").EntireColumn.AutoFit
End Sub


Now I want make a macro that insert a new worksheet and the loads this
automatic macro into the new worksheet. Is this possible?

BR
Trond



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Programming a new macro

Sorry, I made myself unclear.

I have an existing workbook with several worksheets. These sheets have
automatically macros that formats the content by using Worksheet_Change. I
want to insert another sheet in my workbook. I want this sheet to contain
this automatic macro that formats the content in my new sheet. Do I have to
copy the text into the sheet in VBA or can I make a macro that does this job
for me?

Trond

Nigel skrev:

Save the workbook with the code as a template and then when you require a
new workbook open the template, this will create a new workbook (with the
code) and rename the workbook sequentially e.g. if you called the template
MyCodeBook then when you open the template the new workbook will be named
MyCodeBook1, the next one MyCodeBook2 etc....


--
Cheers
Nigel



"Trond" wrote in message
...
I have a macro that automatically controls the format of cells in a

worksheet.
Example:
Sheet1
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then Range("A1").EntireColumn.AutoFit
End Sub


Now I want make a macro that insert a new worksheet and the loads this
automatic macro into the new worksheet. Is this possible?

BR
Trond




  #4   Report Post  
Posted to microsoft.public.excel.programming
sgl sgl is offline
external usenet poster
 
Posts: 80
Default Programming a new macro

Hi Trond,

Try creating a "Master" wksheet in the wkbook which is a hidden wksheet. In
the "Master" Wksheet place the Worksheet_Change code and use the following
code on a button in the wkbook each time you add a new sheet to the wkbook.

ActiveWorkbook.Sheets("Master").Copy after:=Worksheets("Report")
ActiveSheet.Visible = True

This is a snipet of the code that I use in my particular workbook. Place
the new sheet anywhere you want

Hope this is of assistance
Rgds/sgl

"Trond" wrote:

Sorry, I made myself unclear.

I have an existing workbook with several worksheets. These sheets have
automatically macros that formats the content by using Worksheet_Change. I
want to insert another sheet in my workbook. I want this sheet to contain
this automatic macro that formats the content in my new sheet. Do I have to
copy the text into the sheet in VBA or can I make a macro that does this job
for me?

Trond

Nigel skrev:

Save the workbook with the code as a template and then when you require a
new workbook open the template, this will create a new workbook (with the
code) and rename the workbook sequentially e.g. if you called the template
MyCodeBook then when you open the template the new workbook will be named
MyCodeBook1, the next one MyCodeBook2 etc....


--
Cheers
Nigel



"Trond" wrote in message
...
I have a macro that automatically controls the format of cells in a

worksheet.
Example:
Sheet1
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then Range("A1").EntireColumn.AutoFit
End Sub


Now I want make a macro that insert a new worksheet and the loads this
automatic macro into the new worksheet. Is this possible?

BR
Trond




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Programming a new macro

Thank you! Briliant!

Trond

sgl skrev:

Hi Trond,

Try creating a "Master" wksheet in the wkbook which is a hidden wksheet. In
the "Master" Wksheet place the Worksheet_Change code and use the following
code on a button in the wkbook each time you add a new sheet to the wkbook.

ActiveWorkbook.Sheets("Master").Copy after:=Worksheets("Report")
ActiveSheet.Visible = True

This is a snipet of the code that I use in my particular workbook. Place
the new sheet anywhere you want

Hope this is of assistance
Rgds/sgl

"Trond" wrote:

Sorry, I made myself unclear.

I have an existing workbook with several worksheets. These sheets have
automatically macros that formats the content by using Worksheet_Change. I
want to insert another sheet in my workbook. I want this sheet to contain
this automatic macro that formats the content in my new sheet. Do I have to
copy the text into the sheet in VBA or can I make a macro that does this job
for me?

Trond

Nigel skrev:

Save the workbook with the code as a template and then when you require a
new workbook open the template, this will create a new workbook (with the
code) and rename the workbook sequentially e.g. if you called the template
MyCodeBook then when you open the template the new workbook will be named
MyCodeBook1, the next one MyCodeBook2 etc....


--
Cheers
Nigel



"Trond" wrote in message
...
I have a macro that automatically controls the format of cells in a
worksheet.
Example:
Sheet1
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then Range("A1").EntireColumn.AutoFit
End Sub


Now I want make a macro that insert a new worksheet and the loads this
automatic macro into the new worksheet. Is this possible?

BR
Trond



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
Macro programming in Excel CarlosD_LongIsland Excel Programming 7 June 24th 08 04:05 PM
Macro programming Kristin Excel Programming 1 September 27th 04 06:27 PM
Excel Macro programming Kass[_2_] Excel Programming 2 January 28th 04 03:04 AM
macro programming problem Dave Murto[_2_] Excel Programming 1 January 3rd 04 02:29 AM
Macro Programming Jamie[_3_] Excel Programming 1 August 27th 03 08:20 PM


All times are GMT +1. The time now is 05:55 PM.

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

About Us

"It's about Microsoft Excel"