#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Copy/Paste

Hi

I have been running this code to split the sheet
(Crystal_Table into seperate suppliers.

What i would like to do is set it up so i could copy
direct from the Original sheet (Crystal_Table) to the file
outfile(File_Name) instead of to a new sheet.

The sheet on the new file is called Data?

I know the how to copy the data but i do not know where to
put the line of code so the code still works properly.

Any help is appreciated.

Sub CopyInvoices()
Dim sCriteria As String
Dim sOriginal As String
Dim sNew As String
Dim i As Long
Dim File_Name As String

File_Name = ActiveWorkbook.Worksheets("Menu").Cells.Range
("D9").Value

Set outfile = Workbooks.Open(File_Name)
With ActiveWorkbook
Application.ScreenUpdating = False
Worksheets("Crystal_Table").Activate

With .ActiveSheet
..Rows(1).Insert
..Range("T1").Value = "Test"
sOriginal = .Name
End With

For i = 3 To .ActiveSheet.Cells(Rows.Count, "H").End
(xlUp).Row
sCriteria = .ActiveSheet.Cells(i, "H").Value
If sCriteria < "" Then
If sCriteria < .ActiveSheet.Cells(i - 1, "H").Value Then
..Worksheets.Add After:=.Worksheets(.Worksheets.Count)
..ActiveSheet.Name = sCriteria
sNew = .ActiveSheet.Name
..Worksheets(sOriginal).Activate
With .ActiveSheet
..Columns("H:H").AutoFilter Field:=1, Criteria1:=sCriteria
..Cells.SpecialCells(xlCellTypeVisible).Copy
End With
With .Worksheets(sNew)
..Paste
..Rows(1).EntireRow.Delete
..Columns("W:AQ").EntireColumn.Delete
..Columns("T:T").EntireColumn.Delete
..Columns("O:R").EntireColumn.Delete
..Columns("M:M").EntireColumn.Delete
..Columns("K:K").EntireColumn.Delete
..Columns("I:I").EntireColumn.Delete
..Columns("G:G").EntireColumn.Delete
..Columns("A:E").EntireColumn.Delete
..Columns("A:H").AutoFit

End With
End If
End If
Next i

..Worksheets(sOriginal).Rows(1).EntireRow.Delete

End With

Application.ScreenUpdating = True
Application.CutCopyMode = False
Workbooks("Remittance Module.xls").Activate

End Sub

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
Can't Copy and Paste or Paste Special between Excel Workbooks wllee Excel Discussion (Misc queries) 5 April 29th 23 03:43 AM
Copy, paste without file name referenced after paste AusTexRich Excel Discussion (Misc queries) 6 September 23rd 08 02:57 AM
Copy; Paste; Paste Special are disabled Mack Neff[_3_] Excel Discussion (Misc queries) 0 April 28th 08 06:29 PM
Excel cut/Paste Problem: Year changes after data is copy and paste Asif Excel Discussion (Misc queries) 2 December 9th 05 05:16 PM
I cannot paste from one workbook to another. Copy works, paste do. JimmyMc Excel Discussion (Misc queries) 1 June 10th 05 03:54 PM


All times are GMT +1. The time now is 05:43 AM.

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"