ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   copying rows between a and b (https://www.excelbanter.com/excel-programming/356704-copying-rows-between-b.html)

oercim

copying rows between a and b
 
Hello, I want to write a macro on excel which makes the below
job:
I will have 2 variables let say a and b. Then , I want to copy
the rows between "row a" and "row b". That is all. I made such an
code,

dim a as integer
dim b as integer
Rows(XXXXXXXXX).Select
Selection.Copy


I cant fill the inside of the Rows( ) function. What is the
suitable way of writing this function? Is there a way? If not, how can
I do this job .Thanks alot.


Don Guillett

copying rows between a and b
 
will this do it?
sub copyrows
rows(1).copy rows(2)
end sub
--
Don Guillett
SalesAid Software

"oercim" wrote in message
ups.com...
Hello, I want to write a macro on excel which makes the below
job:
I will have 2 variables let say a and b. Then , I want to copy
the rows between "row a" and "row b". That is all. I made such an
code,

dim a as integer
dim b as integer
Rows(XXXXXXXXX).Select
Selection.Copy


I cant fill the inside of the Rows( ) function. What is the
suitable way of writing this function? Is there a way? If not, how can
I do this job .Thanks alot.




Chip Pearson

copying rows between a and b
 
Rows(a & ":" & b).Select


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"oercim" wrote in message
ups.com...
Hello, I want to write a macro on excel which makes the
below
job:
I will have 2 variables let say a and b. Then , I want to
copy
the rows between "row a" and "row b". That is all. I made such
an
code,

dim a as integer
dim b as integer
Rows(XXXXXXXXX).Select
Selection.Copy


I cant fill the inside of the Rows( ) function. What is the
suitable way of writing this function? Is there a way? If not,
how can
I do this job .Thanks alot.




Carim

copying rows between a and b
 
Hi Oercim,

If I understand correctly your request :
Sub Macro1()
Dim a As Integer
Dim b As Integer
a = 6
b = 12
Rows(a & ":" & a).Copy
Rows(b & ":" & b).Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.Select
End Sub

HTH
Cheers
Carim


oercim

copying rows between a and b
 
Thanks for help, below code makes the job,
Sub Macro1()
Dim a As Integer
Dim b As Integer
a = 6
b = 12
Rows(a & ":" & b).Select
Selection.Copy
End Sub
Again thanks alot.Cheers



All times are GMT +1. The time now is 02:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com