Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Macro to Paste

Hello,

I'm trying to create a macro that would paste items from a sheet, say Sheet1
range A1:D1 to some of the other worksheets, say Sheets5-Sheet10 Range A1:D1.
I came up with the following macro:

Sub PASTEFORMULAS()

Worksheets("Sheet1").Select
Range("A1:D1").Select
Selection.Copy

For i = 1 To Worksheets.Count
Select Case PasteToWorksheets
Case Worksheets(i).Name = "Sheet1" Or "Sheet2" Or "Sheet3" Or "Sheet4"
Case Else
Range("E10").Select
ActiveSheet.Paste
End Select
Next i
End Sub

That macro generates an error and the line Case Worksheets(i).Name =
"Sheet1" Or "Sheet2" Or "Sheet3" Or "Sheet4" is highlighted. I did not enter
any code for the case when the worksheet is Sheet1, Sheet2, Sheet3, or Sheet4
because I dont want to paste items into those worksheets. I'm not sure how
to fix this.

Any advice you could give would be greatly appreciated!

Sincerely,

Magnivy

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Macro to Paste

Dim Sheet As Worksheet

For Each Sheet In ActiveWorkbook.Sheets
If Sheet.Name < "Sheet1" Then Sheet.Range("A1:D1").Formula =
Sheets("Sheet1").Range("A1:D1").Formula
Next Sheet


"Magnivy" wrote:

Hello,

I'm trying to create a macro that would paste items from a sheet, say Sheet1
range A1:D1 to some of the other worksheets, say Sheets5-Sheet10 Range A1:D1.
I came up with the following macro:

Sub PASTEFORMULAS()

Worksheets("Sheet1").Select
Range("A1:D1").Select
Selection.Copy

For i = 1 To Worksheets.Count
Select Case PasteToWorksheets
Case Worksheets(i).Name = "Sheet1" Or "Sheet2" Or "Sheet3" Or "Sheet4"
Case Else
Range("E10").Select
ActiveSheet.Paste
End Select
Next i
End Sub

That macro generates an error and the line Case Worksheets(i).Name =
"Sheet1" Or "Sheet2" Or "Sheet3" Or "Sheet4" is highlighted. I did not enter
any code for the case when the worksheet is Sheet1, Sheet2, Sheet3, or Sheet4
because I dont want to paste items into those worksheets. I'm not sure how
to fix this.

Any advice you could give would be greatly appreciated!

Sincerely,

Magnivy

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 multiple worksheets of a workbook, and paste onto a Word document ( either create new doc file or paste onto an existing file.) I need this done by VBA, Excel Macro Steven Excel Programming 1 October 17th 05 08:56 AM
Copy and Paste macro needs to paste to a changing cell reference loulou Excel Programming 0 February 24th 05 10:29 AM
Cut and Paste using Macro gives paste special method error Lourens Pentz Excel Programming 3 November 21st 04 10:42 PM
Macro to Paste to specific line, and continue to Paste each time on next row not over tomkarakowski[_2_] Excel Programming 1 May 28th 04 06:50 PM
Macro to Copy/Paste then Paste to Next Line tomkarakowski Excel Programming 1 May 28th 04 01:19 AM


All times are GMT +1. The time now is 07:38 PM.

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"