#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 91
Default copy rows

Hello
I have a few large matrix (16000*60) . and On sheet1,column H is numbered
1 to 16000 irregularly. i want to copy multiple rows entirly to sheet2, when
i select or input number of rows at column H to a box (4 example: 15
,350,12600,...) then, related rows copy to sheet2,all at once.
I need to a macro to do it.
Thank's for any help.

best regards

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default copy rows

Hi,

Try this. Right click Sheet1 sheet tab, view code and paste this in on the
right.
Enter the rows to copy (Numbers in column H) seperated by commas.

Sub Marine()
Dim arrParts() As String
Dim MyRange As Range, CopyRange As Range
Dim LastRow As Long
LastRow = Cells(Cells.Rows.Count, "H").End(xlUp).Row
Set MyRange = Range("H1:H" & LastRow)
response = InputBox("Enter rows to copy in the format nnn,nnn,nn")
arrParts = Split(response, ",")
For Each C In MyRange
For Each strPart In arrParts
If C.Value = Val(strPart) Then
If CopyRange Is Nothing Then
Set CopyRange = C.EntireRow
Else
Set CopyRange = Union(CopyRange, C.EntireRow)
End If
End If
Next
Next

If Not CopyRange Is Nothing Then
LastRow = Sheets("Sheet2").Cells(Cells.Rows.Count, "A").End(xlUp).Row
CopyRange.Copy Sheets("Sheet2").Range("A" & LastRow + 1)
End If
End Sub

Mike

"climate" wrote:

Hello
I have a few large matrix (16000*60) . and On sheet1,column H is numbered
1 to 16000 irregularly. i want to copy multiple rows entirly to sheet2, when
i select or input number of rows at column H to a box (4 example: 15
,350,12600,...) then, related rows copy to sheet2,all at once.
I need to a macro to do it.
Thank's for any help.

best regards

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 91
Default copy rows

Hi Mike
I am grateful for your kindness,the macro works properly.
best regards

"Mike H" wrote:

Hi,

Try this. Right click Sheet1 sheet tab, view code and paste this in on the
right.
Enter the rows to copy (Numbers in column H) seperated by commas.

Sub Marine()
Dim arrParts() As String
Dim MyRange As Range, CopyRange As Range
Dim LastRow As Long
LastRow = Cells(Cells.Rows.Count, "H").End(xlUp).Row
Set MyRange = Range("H1:H" & LastRow)
response = InputBox("Enter rows to copy in the format nnn,nnn,nn")
arrParts = Split(response, ",")
For Each C In MyRange
For Each strPart In arrParts
If C.Value = Val(strPart) Then
If CopyRange Is Nothing Then
Set CopyRange = C.EntireRow
Else
Set CopyRange = Union(CopyRange, C.EntireRow)
End If
End If
Next
Next

If Not CopyRange Is Nothing Then
LastRow = Sheets("Sheet2").Cells(Cells.Rows.Count, "A").End(xlUp).Row
CopyRange.Copy Sheets("Sheet2").Range("A" & LastRow + 1)
End If
End Sub

Mike

"climate" wrote:

Hello
I have a few large matrix (16000*60) . and On sheet1,column H is numbered
1 to 16000 irregularly. i want to copy multiple rows entirly to sheet2, when
i select or input number of rows at column H to a box (4 example: 15
,350,12600,...) then, related rows copy to sheet2,all at once.
I need to a macro to do it.
Thank's for any help.

best regards

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
How do I Copy and Paste onto Same Rows after filtering out rows. TWT Excel Discussion (Misc queries) 2 October 20th 08 04:09 PM
Copy rows from one worksheet automatically, ignore rows that are b Kris Excel Worksheet Functions 2 October 10th 08 09:28 PM
copy of certain rows climate Excel Worksheet Functions 2 February 20th 08 04:53 AM
Copy rows of data (eliminating blank rows) from fixed layout Sweepea Excel Discussion (Misc queries) 1 March 13th 07 11:05 PM
Hide Rows - copy and paste only rows that show Access101 Excel Worksheet Functions 3 March 1st 06 12:39 AM


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