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

Hi!

I have a problem with a Sub that copy selected rows from a excel fil
into another one. I don't know what I'm doing wrong because the firs
time I execute this Sub works, but the second time it doesn't work, an
only insert a new blank cell.


Public Sub CopyItems()

Windows("FirstFile.xls").Application.Range("B9" + ":" + "C15").Select
Windows(("FirstFile.xls").Application.CutCopyMode = False
Selection.EntireRow.Copy

Windows("TargetFile.xls").Activate
Windows("TargetFile.xls").Application.Rows("9:9"). Select
Windows("TargetFile.xls").Application.CutCopyMode = False
Selection.Insert Shift:=xlDown

End sub


Anyone had any time this problem? The fact is that the funtionality i
tested because it works the first time but something must happen th
second time.

Thanks in advance

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default insert selected rows problem

Public Sub CopyItems()

Workbooks("FirstFile.xls").worksheets("Sheet1") _
.Range("B9:C15").Entirerow.copy
Workbooks("TargetFile.xls").Worksheets("Sheet1") _
.Rows(9).EntireRow.Insert Shift:=xldown

End sub

Change the name of the worksheets to reflect the ones you want to work with.

--
Regards,
Tom Ogilvy


"rhplus " wrote in message
...
Hi!

I have a problem with a Sub that copy selected rows from a excel file
into another one. I don't know what I'm doing wrong because the first
time I execute this Sub works, but the second time it doesn't work, and
only insert a new blank cell.


Public Sub CopyItems()

Windows("FirstFile.xls").Application.Range("B9" + ":" + "C15").Select
Windows(("FirstFile.xls").Application.CutCopyMode = False
Selection.EntireRow.Copy

Windows("TargetFile.xls").Activate
Windows("TargetFile.xls").Application.Rows("9:9"). Select
Windows("TargetFile.xls").Application.CutCopyMode = False
Selection.Insert Shift:=xlDown

End sub


Anyone had any time this problem? The fact is that the funtionality is
tested because it works the first time but something must happen the
second time.

Thanks in advance.


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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default insert selected rows problem

Try this
Windows("FirstFile.xls").Application.Range("B9" + ":" + "C15").Selec
Selection.EntireRow.Cop
Windows("TargetFile.xls").Activat
ActiveSheet.Range("a9").Selec
ActiveSheet.Past

----- rhplus wrote: ----

Hi

I have a problem with a Sub that copy selected rows from a excel fil
into another one. I don't know what I'm doing wrong because the firs
time I execute this Sub works, but the second time it doesn't work, an
only insert a new blank cell


Public Sub CopyItems(

Windows("FirstFile.xls").Application.Range("B9" + ":" + "C15").Selec
Windows(("FirstFile.xls").Application.CutCopyMode = Fals
Selection.EntireRow.Cop

Windows("TargetFile.xls").Activat
Windows("TargetFile.xls").Application.Rows("9:9"). Selec
Windows("TargetFile.xls").Application.CutCopyMode = Fals
Selection.Insert Shift:=xlDow

End su


Anyone had any time this problem? The fact is that the funtionality i
tested because it works the first time but something must happen th
second time

Thanks in advance


--
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 rows in Excel Ledger problem Gary Huston New Users to Excel 8 November 15th 09 04:02 PM
Color alternate rows when after hiding selected rows Monk[_2_] Excel Worksheet Functions 6 June 7th 08 01:36 AM
Insert rows: Formats & formulas extended to additonal rows Twishlist Excel Worksheet Functions 0 October 22nd 07 04:23 AM
How can I insert same word into selected column ZigZig Excel Discussion (Misc queries) 1 February 6th 06 09:40 AM
Insert Rows Problem comotoman Excel Discussion (Misc queries) 3 October 7th 05 05:20 PM


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