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: 29
Default Copy problem

Hello,

I have programmed a procedure to copy some ranges to new sheet. it can
finish the job. but the problem is after I finish this marco,and try to close
the datasource workbook. it can not close immediately,it keeps waiting. I
feel too much memory has been occupied. I try to copy in the sheet
manually,I found the last range ,I used to copy,is still im memory. How can
free up this memory? I suppose it can help me to close the workbook.

My macro as following:

Sub Generate_prod3()

Dim BOM As Worksheet

Dim Mingxi As Worksheet

Dim findrng As Range

Dim prod As Range

Dim i As Long, n As Integer

Const Col = 6


'Add new sheet as Mingxi

Sheets.Add after:=ActiveSheet

ActiveSheet.Name = "Mingxi"

Set Mingxi = Sheets("Mingxi")

Mingxi.Previous.Activate


Set BOM = Sheets("零件明细")

'copy the columnwidths to new sheet

BOM.Range("A1:F1").Copy

Mingxi.Range("A1").PasteSpecial xlPasteColumnWidths

BOM.Range("A1:F1").Copy Mingxi.Range("A1")


For i = 1 To Selection.Rows.Count

Set findrng = BOM.Cells.Find(what:=Selection.Cells(i, 1), lookat:=xlWhole)

n = findrng.End(xlDown).Row - findrng.Row

Set prod = findrng.Resize(n - 1, Col)

If i = 1 Then
prod.Copy Destination:=Mingxi.Range("A2")
Else

prod.Copy Destination:=Mingxi.Cells(Mingxi.UsedRange.Rows.Co unt + 2, 1)
End If
Next i

Set prod = Nothing


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
V-Look up copy problem-PLEASE HELP Sekhar Excel Worksheet Functions 3 September 12th 08 09:56 AM
Copy Problem WTG Excel Discussion (Misc queries) 3 March 23rd 07 10:14 PM
copy problem WTG Excel Worksheet Functions 2 March 23rd 07 09:50 PM
A visual basic value copy BUG?? - accounting format has copy problem!! [email protected] Excel Programming 3 June 20th 06 04:42 PM
Copy problem again. Peter[_28_] Excel Programming 4 November 6th 04 12:20 PM


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