#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 42
Default create a macro

I have a sheet 1 with all the info and formula and I want to use macro to
copy that sheet into sheet 2 and where the formula says sheet 1 i want to
change that to sheet 2 and so on for the other sheets.

thank you in advance.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default create a macro

Sub copySheet()
Dim s1 As Worksheet, s2 As Worksheet
Set s1 = Sheets("Sheet1")
Set s2 = Sheets("Sheet2")
s1.Cells.Copy s2.Range("A1")
End Sub

--
Gary''s Student - gsnu200905


"ganga" wrote:

I have a sheet 1 with all the info and formula and I want to use macro to
copy that sheet into sheet 2 and where the formula says sheet 1 i want to
change that to sheet 2 and so on for the other sheets.

thank you in advance.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default create a macro

If you have formulas on Sheet1 why are they referring to Sheet1?

If you delete any Sheet1 references, the formulas will copy as is with no
sheet reference.

If you have a reason for the Sheet1 reference then............

Delete all sheets except Sheet1 then run this macro.

Copies Sheet1 as many times as you designate in the InputBox.

Each Sheet's formulas will refer to their own sheet.

Sub SheetCopy()
Dim I As Long
On Error GoTo endit
Application.ScreenUpdating = False
shts = InputBox("How many times?")
For I = 2 To shts
ActiveSheet.Copy After:=ActiveSheet
With ActiveSheet
.Name = "Sheet" & I
End With
Next I
Application.ScreenUpdating = True
endit:
End Sub


Gord Dibben MS Excel MVP

On Tue, 29 Sep 2009 10:35:02 -0700, ganga
wrote:

I have a sheet 1 with all the info and formula and I want to use macro to
copy that sheet into sheet 2 and where the formula says sheet 1 i want to
change that to sheet 2 and so on for the other sheets.

thank you in advance.


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 42
Default create a macro

it's not really working for me.. can you explain me more.. sorry i'm not
really good in macro

thank you

"ganga" wrote:

I have a sheet 1 with all the info and formula and I want to use macro to
copy that sheet into sheet 2 and where the formula says sheet 1 i want to
change that to sheet 2 and so on for the other sheets.

thank you in advance.

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default create a macro

You had a couple of replies.

Which one isn't working for you?

The macro and instructions I posted work fine for me.

But please answer why you have formulas on Sheet1 that reference Sheet1


Gord Dibben MS Excel MVP


On Wed, 30 Sep 2009 07:48:01 -0700, ganga
wrote:

it's not really working for me.. can you explain me more.. sorry i'm not
really good in macro

thank you

"ganga" wrote:

I have a sheet 1 with all the info and formula and I want to use macro to
copy that sheet into sheet 2 and where the formula says sheet 1 i want to
change that to sheet 2 and so on for the other sheets.

thank you in advance.




  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 42
Default create a macro

Sorry if i confused you. I don't have any formula in sheet 1. but in sheet 2
I have a formula that refer to sheet 1. so I need a macro ( by entering 1 key
or function) to copy that sheet into sheet 3 and so on and change the formula
where it says sheet 1 change to sheet 2 and so on..
I hope this time its clear.

for example:
sheet 1 A1 15
sheet 2 A1 sheet1!+5

By entering a Key or functions i need

sheet 3 A1 sheet2!+5



"Gord Dibben" wrote:

You had a couple of replies.

Which one isn't working for you?

The macro and instructions I posted work fine for me.

But please answer why you have formulas on Sheet1 that reference Sheet1


Gord Dibben MS Excel MVP


On Wed, 30 Sep 2009 07:48:01 -0700, ganga
wrote:

it's not really working for me.. can you explain me more.. sorry i'm not
really good in macro

thank you

"ganga" wrote:

I have a sheet 1 with all the info and formula and I want to use macro to
copy that sheet into sheet 2 and where the formula says sheet 1 i want to
change that to sheet 2 and so on for the other sheets.

thank you in advance.



  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default create a macro

Copy/paste this UDF to a general module in your workbook.

Function PrevSheet(rg As Range)
n = Application.Caller.Parent.Index
If n = 1 Then
PrevSheet = CVErr(xlErrRef)
ElseIf TypeName(Sheets(n - 1)) = "Chart" Then
PrevSheet = CVErr(xlErrNA)
Else
PrevSheet = Sheets(n - 1).Range(rg.Address).Value
End If
End Function

Example of usage...................

Say you have 12 sheets, sheet1 through sheet12...........sheet names don't
matter.

In sheet1 you have 15 in A1

Select sheet2 and SHIFT + Click last sheet tab to group the sheets.

In active sheet A1 enter =prevsheet(A1)+5

Ungroup the sheets.



Gord

On Thu, 1 Oct 2009 10:01:02 -0700, ganga
wrote:

Sorry if i confused you. I don't have any formula in sheet 1. but in sheet 2
I have a formula that refer to sheet 1. so I need a macro ( by entering 1 key
or function) to copy that sheet into sheet 3 and so on and change the formula
where it says sheet 1 change to sheet 2 and so on..
I hope this time its clear.

for example:
sheet 1 A1 15
sheet 2 A1 sheet1!+5

By entering a Key or functions i need

sheet 3 A1 sheet2!+5



"Gord Dibben" wrote:

You had a couple of replies.

Which one isn't working for you?

The macro and instructions I posted work fine for me.

But please answer why you have formulas on Sheet1 that reference Sheet1


Gord Dibben MS Excel MVP


On Wed, 30 Sep 2009 07:48:01 -0700, ganga
wrote:

it's not really working for me.. can you explain me more.. sorry i'm not
really good in macro

thank you

"ganga" wrote:

I have a sheet 1 with all the info and formula and I want to use macro to
copy that sheet into sheet 2 and where the formula says sheet 1 i want to
change that to sheet 2 and so on for the other sheets.

thank you in advance.




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
Create a macro massa Excel Discussion (Misc queries) 1 June 8th 09 04:15 PM
create a macro trinab Excel Discussion (Misc queries) 1 September 30th 08 11:13 PM
Macro to Create .pdf dv_it Excel Discussion (Misc queries) 0 March 6th 08 04:21 PM
Trying to Create a Macro [email protected] Excel Worksheet Functions 1 July 27th 06 10:03 PM
Using a macro to create a macro in another workbook Gizmo63 Excel Worksheet Functions 2 May 15th 06 09:48 AM


All times are GMT +1. The time now is 02:34 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"