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

Hello All,
When I run this macro it gives me "copy mehtod of range class failed"
Can someone pls help me. All I doing is to let it get the ranges an
insert in order form at range A12.
I have Excel2000

Saziz

Sheets("Mixing Coating").Select
Set rng = ActiveSheet.Range("H12:H25")
For Each cell In rng

If cell.Value < "" And cell.Value < 5 Then
cell.Offset(0, -7).Resize(1, 4).Copy _
Worksheets("OrderForm").Range("A12").Insert





End If
Nex

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default copy insert problem

First you donot need the insert at the end of the copy
statement. Then surely you need to shift the cell where
the data is pasted to after each iteration otherwise the
new data simply overwrites the data in A12. Hence I have
added a variable a =12 to start at A12 then increment that
by 1 to then goto A13 A14 and so on.

Sheets("Mixing Coating").Select
Set rng = ActiveSheet.Range("H12:H25")
a=12

For Each cell In rng

If cell.Value < "" And cell.Value < 5 Then
cell.Offset(0, -7).Resize(1, 4).Copy _
(Worksheets("OrderForm").Range("A"&a))


End If

a=a+1

Next

Hope this helps

DavidC

-----Original Message-----
Hello All,
When I run this macro it gives me "copy mehtod of range

class failed"
Can someone pls help me. All I doing is to let it get

the ranges and
insert in order form at range A12.
I have Excel2000

Saziz

Sheets("Mixing Coating").Select
Set rng = ActiveSheet.Range("H12:H25")
For Each cell In rng

If cell.Value < "" And cell.Value < 5 Then
cell.Offset(0, -7).Resize(1, 4).Copy _
Worksheets("OrderForm").Range("A12").Insert





End If
Next


---
Message posted from http://www.ExcelForum.com/

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default copy insert problem

David,
Thanks for ur help, Its working. But it also is creating empty ro
after each iteration. I guess because we gave the incriment a= a+1.
So I need to insert a code to delete empty rows. How would I do that?
Sazi

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default copy insert problem

No need to delete any rows. I just had the a=a+1 in the
wrong place. Try this code below:

Sheets("Mixing Coating").Select
Set rng = ActiveSheet.Range("H12:H25")
a = 12

For Each cell In rng

If cell.Value < "" And cell.Value < 5 Then
cell.Offset(0, -7).Resize(1, 4).Copy _
(Worksheets("OrderForm").Range("A" & a))

a = a + 1

Else

End If

Next

Best of luck
DavidC
-----Original Message-----
David,
Thanks for ur help, Its working. But it also is

creating empty row
after each iteration. I guess because we gave the

incriment a= a+1.
So I need to insert a code to delete empty rows. How

would I do that?
Saziz


---
Message posted from http://www.ExcelForum.com/

.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default copy insert problem

David, it worked perfectly.
Thanks a bunch
Sazi

--
Message posted from http://www.ExcelForum.com

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
insert and copy Darius Excel Worksheet Functions 3 April 22nd 09 08:45 AM
Copy and insert dee Excel Discussion (Misc queries) 0 April 8th 08 11:30 AM
Copy and paste versus copy and insert copied cells Alana New Users to Excel 1 September 28th 07 08:58 PM
Move/Copy or Copy/Insert worksheet? kjk Excel Discussion (Misc queries) 0 December 15th 06 02:40 PM
Copy & Insert from another xls JWF Excel Discussion (Misc queries) 1 March 14th 06 12:08 PM


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