LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Setting a range within a loop variable for copy/paste

i'm trying to select the range of cells within a row to copy to another
sheet and transpose, it's in the middle of some code that runs a loop
to create new sheets based on entries on the first sheet. It keeps
bombing out on the paste command, and i can't figure out why, is it
clearing the clipboard when the new sheet is created so there's nothing
to paste or is something else wrong, i can't figure it out, any ideas,
here's what i have so far, it flags the last line
(selection.pastespecial). thanks in advance for any help

Sub newSheet()
Dim MyRange As Range
Dim C As Range
Dim NewSheetName As String
Dim newSheet As Worksheet
Dim xLastRow As Long
xLastRow = Cells(Rows.Count, "A").End(xlUp).Row
Set MyRange = Range("A6:A" & xLastRow)
For Each C In MyRange
NewSheetName = C.Value
C.Select
Rows(ActiveCell.Row).Select
Selection.Copy
Set newSheet = Sheets.Add
With newSheet
.Move After:=Worksheets(Worksheets.Count)
On Error Resume Next
.Name = NewSheetName
On Error GoTo 0
End With
Range("C5").Select
Selection.PasteSpecial Paste:=xlPasteValues,
Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Next C

End Sub

 
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
How to copy&paste a variable range rows and colums IK Excel Discussion (Misc queries) 1 August 30th 06 12:06 AM
Loop: Copy and paste range that changes with every iteration Allen Geddes Excel Programming 0 November 15th 05 12:58 PM
Copy/paste range variable between workbooks Jim73 Excel Programming 2 January 14th 05 08:17 AM
setting a range variable equal to the value of a string variable Pilgrim Excel Programming 2 July 1st 04 11:32 PM
Setting range value to a variable Todd Excel Programming 4 June 2nd 04 04:51 PM


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