Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 394
Default Copy & Paste Special Using Values

Hi Everybody,

I would like VBA Code that is Similar to the One Below ( but Not
Adapting the One Below, I Still want to Use it as it is ) which Works a
Treat ...

Code:
Sub SheetInsert()
Dim s1 As String, s2 As String
Dim x As Long, y As Long, i As Long
Dim pasteto As String
Application.ScreenUpdating = False

s1 = "How many sheets would you like to add?"
s2 = "What would you like the number of the first sheet to be?"
x = InputBox(s1)
y = InputBox(s2, "Insert Sheets")

For i = 1 To x
Sheets.Add After:=Sheets(Sheets.Count)
pasteto = i + y - 1
ActiveSheet.Name = pasteto
With Sheets(pasteto)
Sheets("Master").Cells.Copy _
Destination:=.Range("A1")
.Range("A1").Value = .Name
.Range("B22").Select
End With
Next i

Application.ScreenUpdating = True
End Sub

.... to Ask me in the First Box which Sheet to Start with, and the
Second Box to Ask me which Sheet to End with ( the Sheets are Numbered
1 to Whatever for Example ).
I then want Each of those Sheets to be Highlighted in the Top Left Hand
Corner so it Selects ALL of the Sheet, and for ALL of the Sheets
Specified. I then want to Copy and Paste Special Using Values.
And Finally, I would like the Cursor to End Up in Cell B22 of EVERY
Sheet Please.

Thanks in Advance.
All the Best.
Paul

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Copy & Paste Special Using Values

This does it...
..
Sub SheetCopyValues()
Dim s1 As String, s2 As String
Dim x As Long, y As Long, i As Long
Dim pasteto As String
Application.ScreenUpdating = False

s1 = "Enter number of first sheet"
s2 = "Enter number of last sheet"
x = InputBox(s1, "First Sheet to copy to")
y = InputBox(s2, "Last Sheet to copy to")

For i = x To y
Sheets("Master").Cells.Copy
On Error Resume Next
With Sheets(CStr(i))
.Activate
.Range("A1").PasteSpecial Paste:=xlPasteValues
.Range("A1") = .Name
.Range("B22").Select
End With
Next i
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub



--
Cheers
Nigel



"Paul Black" wrote in message
ups.com...
Hi Everybody,

I would like VBA Code that is Similar to the One Below ( but Not
Adapting the One Below, I Still want to Use it as it is ) which Works a
Treat ...

Code:
Sub SheetInsert()
Dim s1 As String, s2 As String
Dim x As Long, y As Long, i As Long
Dim pasteto As String
Application.ScreenUpdating = False

s1 = "How many sheets would you like to add?"
s2 = "What would you like the number of the first sheet to be?"
x = InputBox(s1)
y = InputBox(s2, "Insert Sheets")

For i = 1 To x
Sheets.Add After:=Sheets(Sheets.Count)
pasteto = i + y - 1
ActiveSheet.Name = pasteto
With Sheets(pasteto)
Sheets("Master").Cells.Copy _
Destination:=.Range("A1")
.Range("A1").Value = .Name
.Range("B22").Select
End With
Next i

Application.ScreenUpdating = True
End Sub

... to Ask me in the First Box which Sheet to Start with, and the
Second Box to Ask me which Sheet to End with ( the Sheets are Numbered
1 to Whatever for Example ).
I then want Each of those Sheets to be Highlighted in the Top Left Hand
Corner so it Selects ALL of the Sheet, and for ALL of the Sheets
Specified. I then want to Copy and Paste Special Using Values.
And Finally, I would like the Cursor to End Up in Cell B22 of EVERY
Sheet Please.

Thanks in Advance.
All the Best.
Paul



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 394
Default Copy & Paste Special Using Values

Hi Nigel,

Thanks for the Reply.
What my Original Macro does is Copy x Number of the Sheet Named
"Master" and Insert them After the Sheet Number I put in Box 1 Until it
Reaches the Sheet Number I put in Box 2.
This is OK but you can Appreciate that After Several Hundred Inserts of
Sheets the File Size gets Quite Big Because of All the Formulas.
Ideally the New Macro will go from the Sheet Number I Specify in Box 1
Until the Sheet Number I Specify in Box 2, and Transfer All the
Formulas to Values and Leave the Cursor on Cell B22.
My Appologies for Not Explaining Myself Clearly Enough in my Original
Post.

Thanks in Advance.
All the Best.
Paul

Nigel wrote:
This does it...
.
Sub SheetCopyValues()
Dim s1 As String, s2 As String
Dim x As Long, y As Long, i As Long
Dim pasteto As String
Application.ScreenUpdating = False

s1 = "Enter number of first sheet"
s2 = "Enter number of last sheet"
x = InputBox(s1, "First Sheet to copy to")
y = InputBox(s2, "Last Sheet to copy to")

For i = x To y
Sheets("Master").Cells.Copy
On Error Resume Next
With Sheets(CStr(i))
.Activate
.Range("A1").PasteSpecial Paste:=xlPasteValues
.Range("A1") = .Name
.Range("B22").Select
End With
Next i
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub



--
Cheers
Nigel



"Paul Black" wrote in message
ups.com...
Hi Everybody,

I would like VBA Code that is Similar to the One Below ( but Not
Adapting the One Below, I Still want to Use it as it is ) which Works a
Treat ...

Code:
Sub SheetInsert()
Dim s1 As String, s2 As String
Dim x As Long, y As Long, i As Long
Dim pasteto As String
Application.ScreenUpdating = False

s1 = "How many sheets would you like to add?"
s2 = "What would you like the number of the first sheet to be?"
x = InputBox(s1)
y = InputBox(s2, "Insert Sheets")

For i = 1 To x
Sheets.Add After:=Sheets(Sheets.Count)
pasteto = i + y - 1
ActiveSheet.Name = pasteto
With Sheets(pasteto)
Sheets("Master").Cells.Copy _
Destination:=.Range("A1")
.Range("A1").Value = .Name
.Range("B22").Select
End With
Next i

Application.ScreenUpdating = True
End Sub

... to Ask me in the First Box which Sheet to Start with, and the
Second Box to Ask me which Sheet to End with ( the Sheets are Numbered
1 to Whatever for Example ).
I then want Each of those Sheets to be Highlighted in the Top Left Hand
Corner so it Selects ALL of the Sheet, and for ALL of the Sheets
Specified. I then want to Copy and Paste Special Using Values.
And Finally, I would like the Cursor to End Up in Cell B22 of EVERY
Sheet Please.

Thanks in Advance.
All the Best.
Paul


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Copy & Paste Special Using Values

Minor changes required -- see below

Sub SheetCopyValues()
Dim s1 As String, s2 As String
Dim x As Long, y As Long, i As Long

Application.ScreenUpdating = False
s1 = "Enter number of first sheet"
s2 = "Enter number of last sheet"
x = InputBox(s1, "First Sheet to copy to")
y = InputBox(s2, "Last Sheet to copy to")

For i = x To y
On Error Resume Next
With Sheets(CStr(i))
.Activate
.Cells.Copy
.Range("A1").PasteSpecial Paste:=xlPasteValues
.Range("A1") = .Name
Application.CutCopyMode = False
.Range("B22").Select
End With
Next i

Application.ScreenUpdating = True
End Sub

--
Cheers
Nigel



"Paul Black" wrote in message
oups.com...
Hi Nigel,

Thanks for the Reply.
What my Original Macro does is Copy x Number of the Sheet Named
"Master" and Insert them After the Sheet Number I put in Box 1 Until it
Reaches the Sheet Number I put in Box 2.
This is OK but you can Appreciate that After Several Hundred Inserts of
Sheets the File Size gets Quite Big Because of All the Formulas.
Ideally the New Macro will go from the Sheet Number I Specify in Box 1
Until the Sheet Number I Specify in Box 2, and Transfer All the
Formulas to Values and Leave the Cursor on Cell B22.
My Appologies for Not Explaining Myself Clearly Enough in my Original
Post.

Thanks in Advance.
All the Best.
Paul

Nigel wrote:
This does it...
.
Sub SheetCopyValues()
Dim s1 As String, s2 As String
Dim x As Long, y As Long, i As Long
Dim pasteto As String
Application.ScreenUpdating = False

s1 = "Enter number of first sheet"
s2 = "Enter number of last sheet"
x = InputBox(s1, "First Sheet to copy to")
y = InputBox(s2, "Last Sheet to copy to")

For i = x To y
Sheets("Master").Cells.Copy
On Error Resume Next
With Sheets(CStr(i))
.Activate
.Range("A1").PasteSpecial Paste:=xlPasteValues
.Range("A1") = .Name
.Range("B22").Select
End With
Next i
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub



--
Cheers
Nigel



"Paul Black" wrote in message
ups.com...
Hi Everybody,

I would like VBA Code that is Similar to the One Below ( but Not
Adapting the One Below, I Still want to Use it as it is ) which Works a
Treat ...

Code:
Sub SheetInsert()
Dim s1 As String, s2 As String
Dim x As Long, y As Long, i As Long
Dim pasteto As String
Application.ScreenUpdating = False

s1 = "How many sheets would you like to add?"
s2 = "What would you like the number of the first sheet to be?"
x = InputBox(s1)
y = InputBox(s2, "Insert Sheets")

For i = 1 To x
Sheets.Add After:=Sheets(Sheets.Count)
pasteto = i + y - 1
ActiveSheet.Name = pasteto
With Sheets(pasteto)
Sheets("Master").Cells.Copy _
Destination:=.Range("A1")
.Range("A1").Value = .Name
.Range("B22").Select
End With
Next i

Application.ScreenUpdating = True
End Sub

... to Ask me in the First Box which Sheet to Start with, and the
Second Box to Ask me which Sheet to End with ( the Sheets are Numbered
1 to Whatever for Example ).
I then want Each of those Sheets to be Highlighted in the Top Left Hand
Corner so it Selects ALL of the Sheet, and for ALL of the Sheets
Specified. I then want to Copy and Paste Special Using Values.
And Finally, I would like the Cursor to End Up in Cell B22 of EVERY
Sheet Please.

Thanks in Advance.
All the Best.
Paul




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default Copy & Paste Special Using Values

Thanks for the Reply Nigel.

Your Code Works Great if there are NO Merged Cells in Any of the Sheets.
Unfortunately I have Several Merged Cells in Each of the Sheets.

Thanks in Advance.
All the Best.
Paul



*** Sent via Developersdex http://www.developersdex.com ***


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Copy & Paste Special Using Values

Unmerge them first, they are not a good idea anyway!

--
Cheers
Nigel



"Paul Black" wrote in message
...
Thanks for the Reply Nigel.

Your Code Works Great if there are NO Merged Cells in Any of the Sheets.
Unfortunately I have Several Merged Cells in Each of the Sheets.

Thanks in Advance.
All the Best.
Paul



*** Sent via Developersdex http://www.developersdex.com ***



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
Copy Values only without Paste Special karl Excel Discussion (Misc queries) 6 December 22nd 08 02:03 AM
Macro to copy and paste special values bobby Excel Programming 1 November 7th 05 08:06 AM
Copy Paste Special Values Brian Matlack[_11_] Excel Programming 1 October 17th 05 05:22 PM
copy paste special values mike allen[_2_] Excel Programming 7 October 12th 05 06:06 PM
Dynamic Copy/Paste Special Formulas/Paste Special Values Sharon Perez Excel Programming 3 August 7th 04 09:49 PM


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