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

Hi
I have a matrix (1000 * 60), and column H is numbered 1 to 1000 irregularly.
I want to try copy and extract row for example number700 to sheet2 when i
select number of that row.in fact when i enter number of any rows, a formula
or macro copy entire of its row to sheet2.
Thank's and regards
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 364
Default row selecting

Try this macro... read the rows marked with '

Sub CopyToSheet()

'You will need to run this after entering the value in cell A1 of Sheet1
'Row with number in Col H equal to the number in cell A1 of sheet1
'will be copied to row 1 of Sheet2

'Cell Sheet1!A1 must contain a number otherwise this macro will fail

Dim myrange As Range
Dim LastRow As Long
Dim c
Dim i As Integer
Sheets("Sheet1").Activate
i = Cells(1, 1).Value
LastRow = Cells(Rows.Count, "H").End(xlUp).Row
Set myrange = Range("H1:H" & LastRow)
For Each c In myrange
If c.Value = i Then
Cells(i, 1).EntireRow.Copy
Sheets("Sheet2").Activate
Cells(1, 1).Select
ActiveSheet.Paste
MsgBox "Row " & i & " copied to Sheet1 Row 1"
Exit For
End If
Next c
End Sub


"climate" wrote:

Hi
I have a matrix (1000 * 60), and column H is numbered 1 to 1000 irregularly.
I want to try copy and extract row for example number700 to sheet2 when i
select number of that row.in fact when i enter number of any rows, a formula
or macro copy entire of its row to sheet2.
Thank's and regards

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,934
Default row selecting

If I understand you correctly, you want to specify a number that can be
found in Column H and copy its entire row from Sheet1 (you didn't specify
this sheet name, so I guessed it) to Sheet2. If so, give this a try...

Sub CopyRow()
Dim Answer As String
Dim LastRowOnSheet2 As Long
With Worksheets("Sheet2")
LastRowOnSheet2 = .Cells(.Rows.Count, "A").End(xlUp).Row
If LastRowOnSheet2 = 1 And .Cells(1, "A").Value = "" Then
LastRowOnSheet2 = 0
End If
Answer = InputBox("Find which number in Row H and copy it?")
Worksheets("Sheet1").Columns("H").Find(Answer).Ent ireRow. _
Copy .Range("A" & (LastRowOnSheet2 + 1))
End With
End Sub

--
Rick (MVP - Excel)


"climate" wrote in message
...
Hi
I have a matrix (1000 * 60), and column H is numbered 1 to 1000
irregularly.
I want to try copy and extract row for example number700 to sheet2 when i
select number of that row.in fact when i enter number of any rows, a
formula
or macro copy entire of its row to sheet2.
Thank's and regards


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 91
Default row selecting

Hi Rick
Your macro works correctly, thank's for your help.
best regards

"Rick Rothstein" wrote:

If I understand you correctly, you want to specify a number that can be
found in Column H and copy its entire row from Sheet1 (you didn't specify
this sheet name, so I guessed it) to Sheet2. If so, give this a try...

Sub CopyRow()
Dim Answer As String
Dim LastRowOnSheet2 As Long
With Worksheets("Sheet2")
LastRowOnSheet2 = .Cells(.Rows.Count, "A").End(xlUp).Row
If LastRowOnSheet2 = 1 And .Cells(1, "A").Value = "" Then
LastRowOnSheet2 = 0
End If
Answer = InputBox("Find which number in Row H and copy it?")
Worksheets("Sheet1").Columns("H").Find(Answer).Ent ireRow. _
Copy .Range("A" & (LastRowOnSheet2 + 1))
End With
End Sub

--
Rick (MVP - Excel)


"climate" wrote in message
...
Hi
I have a matrix (1000 * 60), and column H is numbered 1 to 1000
irregularly.
I want to try copy and extract row for example number700 to sheet2 when i
select number of that row.in fact when i enter number of any rows, a
formula
or macro copy entire of its row to sheet2.
Thank's and 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
SELECTING LAST ROW da Excel Discussion (Misc queries) 10 August 2nd 08 01:11 AM
Selecting the Same Steve COR Excel Discussion (Misc queries) 0 January 2nd 08 04:13 PM
Selecting Hutchy Excel Discussion (Misc queries) 3 October 12th 07 11:43 AM
VBA - Selecting a Row Elise148 Excel Discussion (Misc queries) 5 June 12th 07 04:29 PM
Selecting every odd row instauratio Excel Discussion (Misc queries) 2 June 15th 05 08:27 PM


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