Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default Copy and paste range instead of entire row


Tried this code, but getting errors on "copy and paste area are not
the same size and shape".
Any way to change this code, to copy range instead of entire row?
Orignal Data is in column A:G, destination is M2.


Sub Cop_Corrects()
'copy rows to worksheets based on value in column A
'assume the worksheet name to paste to is the value in Col A
Dim CurrentCell As Range
Dim SourceRow As Range
Dim Targetsht As Worksheet
Dim TargetRow As Long
Dim CurrentCellValue As String


'start with cell A1 on Sheet1
Set CurrentCell = Worksheets("all corrects").Cells(1, 2) 'row 1
Column 1


Do While Not IsEmpty(CurrentCell)
CurrentCellValue = CurrentCell.Value
Set SourceRow = CurrentCell.EntireRow


'Check if worksheet exists
On Error Resume Next
Testwksht = Worksheets(CurrentCellValue).Name
If Err.Number = 0 Then
'MsgBox CurrentCellValue & " worksheet Exists"
Else
'TO INSERT SHEETS BEFORE A SPECIFIED SHEET, CHANGE NAME BELOW
(END)
Worksheets.Add(befo=Sheets("TA_END")).Name =
CurrentCellValue
End If


On Error GoTo 0 'reset on error to trap errors again


Set Targetsht = ActiveWorkbook.Worksheets(CurrentCellValue)
'note: using CurrentCell.value gave me an error if the value was
numeric


' Find next blank row in Targetsht - check using Column A
TargetRow = Targetsht.Cells(Rows.Count, 1).End(xlUp).Row + 1
SourceRow.Copy Destination:=Targetsht.Cells(TargetRow, 13)


'do the next cell
Set CurrentCell = CurrentCell.Offset(1, 0)
Loop
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default Copy and paste range instead of entire row

thanx but cancel this...

Experts returned to my previous post. Hoping to work this out.

THanx
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
How can I copy and paste an entire workbook? Jordon Excel Worksheet Functions 4 April 3rd 23 02:13 PM
Use loop to filter, copy/paste to new sheet; run through entire li ryguy7272 Excel Programming 2 November 25th 08 03:27 PM
Find Multiple Values, Copy Entire Row & Paste ryguy7272 Excel Programming 10 September 27th 07 10:48 PM
how do i copy an entire workbook and paste it in another BELINDA New Users to Excel 1 June 11th 07 01:02 PM
want to copy entire text box and paste in new cell delbridk Excel Discussion (Misc queries) 4 October 2nd 06 05:33 PM


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