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 and Insert Using VBA


Hello,

I have a problem in VBA that i can't get my head around...

I have two rows of data.. One on row 17 and one on row 31 of the same
tab. I need VBA to copy the row (both 17 & 31) and insert a new copied
row underneath... The probem is that when i run it again, because of
the insert from row 17 it needs to copy row 32 but it re copys 31,
which eventually becomes a header...?

How do i get it to effectivly follow row 31 and grow as the data
does..

Thanks alot

Mike


--
Mikey2005
------------------------------------------------------------------------
Mikey2005's Profile: http://www.excelforum.com/member.php...o&userid=31316
View this thread: http://www.excelforum.com/showthread...hreadid=510664

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default Copy and Insert Using VBA

You can use named ranges and refer to the named range in your code, instead
of the hard coded row numbers. If you want help with that you will need to
post your code...
--
HTH...

Jim Thomlinson


"Mikey2005" wrote:


Hello,

I have a problem in VBA that i can't get my head around...

I have two rows of data.. One on row 17 and one on row 31 of the same
tab. I need VBA to copy the row (both 17 & 31) and insert a new copied
row underneath... The probem is that when i run it again, because of
the insert from row 17 it needs to copy row 32 but it re copys 31,
which eventually becomes a header...?

How do i get it to effectivly follow row 31 and grow as the data
does..

Thanks alot

Mike


--
Mikey2005
------------------------------------------------------------------------
Mikey2005's Profile: http://www.excelforum.com/member.php...o&userid=31316
View this thread: http://www.excelforum.com/showthread...hreadid=510664


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy and Insert Using VBA


My script currently reads:

Sub Copyandpaste()
'
' Copyandpaste Macro
' Macro recorded 09/02/2006 by michael.hebblewhite
'

'
Rows("17:17").Select
Selection.Copy
Rows("18:18").Select
Selection.Insert Shift:=xlDown
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
ActiveWindow.SmallScroll Down:=12
Rows("32:32").Select
Application.CutCopyMode = False
Selection.Copy
Rows("33:33").Select
Selection.Insert Shift:=xlDown
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
ActiveWindow.SmallScroll Down:=-30
Range("A1").Select
ActiveWindow.SmallScroll Down:=0
End Sub

Its the second copy and paste thats the issue.....


--
Mikey2005
------------------------------------------------------------------------
Mikey2005's Profile: http://www.excelforum.com/member.php...o&userid=31316
View this thread: http://www.excelforum.com/showthread...hreadid=510664

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy and Insert Using VBA


Still cant get my head around it....

Cheers....


--
Mikey2005
------------------------------------------------------------------------
Mikey2005's Profile: http://www.excelforum.com/member.php...o&userid=31316
View this thread: http://www.excelforum.com/showthread...hreadid=510664

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 11:19 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"