PC Review


Reply
Thread Tools Rate Thread

copy multiple rows

 
 
climate
Guest
Posts: n/a
 
      29th Apr 2010
Hi
I have following code for row selecting based on number of column G and copy
to sheet (winter), but i have 2 problem. 1) for example: when i input 38 to
box, row with number of 13856 be selected. 2) i need to select multiple row
for copy to sheet1 not one row.
Sub CopyRow()
Dim Answer As String
Dim LastRowOnwinter As Long
With Worksheets("sheet1")
LastRowOnwinter = .Cells(.Rows.Count, "A").End(xlUp).Row
If LastRowOnwinter = 1 And .Cells(1, "A").Value = "" Then
LastRowOnwinter = 0
End If
Answer = InputBox("Find which number in row G and copy it?")
Worksheets("winter").Columns("G").Find(Answer).EntireRow. _
Copy .Range("A" & (LastRowOnwinter + 1))
End With
End Sub

Would you please guide me?
regards
 
Reply With Quote
 
 
 
 
Jacob Skaria
Guest
Posts: n/a
 
      29th Apr 2010
Try the below. Edit the sheet names to suit...

Sub CopyRow()
Dim ws1 As Worksheet, ws2 As Worksheet
Dim varFound As Variant, varSearch As Variant
Dim strAddress As String, lngLastRow As Long

Set ws1 = Sheets("Sheet1") 'source sheet
Set ws2 = Sheets("Sheet2") 'destination sheet

varSearch = InputBox("Find which number in row G and copy it?")
If varSearch = "" Then Exit Sub

With ws1.Columns("G")
Set varFound = .Find(varSearch, LookIn:=xlValues, LookAt:=xlWhole)
If Not varFound Is Nothing Then
strAddress = varFound.Address
Do
lngLastRow = ws2.Cells(Rows.Count, "G").End(xlUp).Row + 1
ws1.Rows(varFound.Row).Copy ws2.Rows(lngLastRow)
Set varFound = .FindNext(varFound)
Loop While Not varFound Is Nothing And _
varFound.Address <> strAddress
End If
End With
End Sub

--
Jacob (MVP - Excel)


"climate" wrote:

> Hi
> I have following code for row selecting based on number of column G and copy
> to sheet (winter), but i have 2 problem. 1) for example: when i input 38 to
> box, row with number of 13856 be selected. 2) i need to select multiple row
> for copy to sheet1 not one row.
> Sub CopyRow()
> Dim Answer As String
> Dim LastRowOnwinter As Long
> With Worksheets("sheet1")
> LastRowOnwinter = .Cells(.Rows.Count, "A").End(xlUp).Row
> If LastRowOnwinter = 1 And .Cells(1, "A").Value = "" Then
> LastRowOnwinter = 0
> End If
> Answer = InputBox("Find which number in row G and copy it?")
> Worksheets("winter").Columns("G").Find(Answer).EntireRow. _
> Copy .Range("A" & (LastRowOnwinter + 1))
> End With
> End Sub
>
> Would you please guide me?
> regards

 
Reply With Quote
 
climate
Guest
Posts: n/a
 
      29th Apr 2010
Hello Jacob
Thank you, but my second problem is exist. i want to select several rows not
one row.
regards

"Jacob Skaria" wrote:

> Try the below. Edit the sheet names to suit...
>
> Sub CopyRow()
> Dim ws1 As Worksheet, ws2 As Worksheet
> Dim varFound As Variant, varSearch As Variant
> Dim strAddress As String, lngLastRow As Long
>
> Set ws1 = Sheets("Sheet1") 'source sheet
> Set ws2 = Sheets("Sheet2") 'destination sheet
>
> varSearch = InputBox("Find which number in row G and copy it?")
> If varSearch = "" Then Exit Sub
>
> With ws1.Columns("G")
> Set varFound = .Find(varSearch, LookIn:=xlValues, LookAt:=xlWhole)
> If Not varFound Is Nothing Then
> strAddress = varFound.Address
> Do
> lngLastRow = ws2.Cells(Rows.Count, "G").End(xlUp).Row + 1
> ws1.Rows(varFound.Row).Copy ws2.Rows(lngLastRow)
> Set varFound = .FindNext(varFound)
> Loop While Not varFound Is Nothing And _
> varFound.Address <> strAddress
> End If
> End With
> End Sub
>
> --
> Jacob (MVP - Excel)
>
>
> "climate" wrote:
>
> > Hi
> > I have following code for row selecting based on number of column G and copy
> > to sheet (winter), but i have 2 problem. 1) for example: when i input 38 to
> > box, row with number of 13856 be selected. 2) i need to select multiple row
> > for copy to sheet1 not one row.
> > Sub CopyRow()
> > Dim Answer As String
> > Dim LastRowOnwinter As Long
> > With Worksheets("sheet1")
> > LastRowOnwinter = .Cells(.Rows.Count, "A").End(xlUp).Row
> > If LastRowOnwinter = 1 And .Cells(1, "A").Value = "" Then
> > LastRowOnwinter = 0
> > End If
> > Answer = InputBox("Find which number in row G and copy it?")
> > Worksheets("winter").Columns("G").Find(Answer).EntireRow. _
> > Copy .Range("A" & (LastRowOnwinter + 1))
> > End With
> > End Sub
> >
> > Would you please guide me?
> > regards

 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      29th Apr 2010
--The macro copies all rows containing the search value in ColG.

--If you mean to copy subsequent rows to the other sheet; then you havent
mentioned how many rows to be copied or the criteria to know how many
subsequent rows are to be copied.

Post back with sample data.

--
Jacob (MVP - Excel)


"climate" wrote:

> Hello Jacob
> Thank you, but my second problem is exist. i want to select several rows not
> one row.
> regards
>
> "Jacob Skaria" wrote:
>
> > Try the below. Edit the sheet names to suit...
> >
> > Sub CopyRow()
> > Dim ws1 As Worksheet, ws2 As Worksheet
> > Dim varFound As Variant, varSearch As Variant
> > Dim strAddress As String, lngLastRow As Long
> >
> > Set ws1 = Sheets("Sheet1") 'source sheet
> > Set ws2 = Sheets("Sheet2") 'destination sheet
> >
> > varSearch = InputBox("Find which number in row G and copy it?")
> > If varSearch = "" Then Exit Sub
> >
> > With ws1.Columns("G")
> > Set varFound = .Find(varSearch, LookIn:=xlValues, LookAt:=xlWhole)
> > If Not varFound Is Nothing Then
> > strAddress = varFound.Address
> > Do
> > lngLastRow = ws2.Cells(Rows.Count, "G").End(xlUp).Row + 1
> > ws1.Rows(varFound.Row).Copy ws2.Rows(lngLastRow)
> > Set varFound = .FindNext(varFound)
> > Loop While Not varFound Is Nothing And _
> > varFound.Address <> strAddress
> > End If
> > End With
> > End Sub
> >
> > --
> > Jacob (MVP - Excel)
> >
> >
> > "climate" wrote:
> >
> > > Hi
> > > I have following code for row selecting based on number of column G and copy
> > > to sheet (winter), but i have 2 problem. 1) for example: when i input 38 to
> > > box, row with number of 13856 be selected. 2) i need to select multiple row
> > > for copy to sheet1 not one row.
> > > Sub CopyRow()
> > > Dim Answer As String
> > > Dim LastRowOnwinter As Long
> > > With Worksheets("sheet1")
> > > LastRowOnwinter = .Cells(.Rows.Count, "A").End(xlUp).Row
> > > If LastRowOnwinter = 1 And .Cells(1, "A").Value = "" Then
> > > LastRowOnwinter = 0
> > > End If
> > > Answer = InputBox("Find which number in row G and copy it?")
> > > Worksheets("winter").Columns("G").Find(Answer).EntireRow. _
> > > Copy .Range("A" & (LastRowOnwinter + 1))
> > > End With
> > > End Sub
> > >
> > > Would you please guide me?
> > > regards

 
Reply With Quote
 
climate
Guest
Posts: n/a
 
      29th Apr 2010
Hi
You are right, yes, i need to copy subsequent rows and maximum 30 rows.
My expected is When i run your code and open box for row number of column
G[38,567,1299,4567,...] then related rows copy to sheet2. criteria is values
in ColG.

Regards

"Jacob Skaria" wrote:

> --The macro copies all rows containing the search value in ColG.
>
> --If you mean to copy subsequent rows to the other sheet; then you havent
> mentioned how many rows to be copied or the criteria to know how many
> subsequent rows are to be copied.
>
> Post back with sample data.
>
> --
> Jacob (MVP - Excel)
>
>
> "climate" wrote:
>
> > Hello Jacob
> > Thank you, but my second problem is exist. i want to select several rows not
> > one row.
> > regards
> >
> > "Jacob Skaria" wrote:
> >
> > > Try the below. Edit the sheet names to suit...
> > >
> > > Sub CopyRow()
> > > Dim ws1 As Worksheet, ws2 As Worksheet
> > > Dim varFound As Variant, varSearch As Variant
> > > Dim strAddress As String, lngLastRow As Long
> > >
> > > Set ws1 = Sheets("Sheet1") 'source sheet
> > > Set ws2 = Sheets("Sheet2") 'destination sheet
> > >
> > > varSearch = InputBox("Find which number in row G and copy it?")
> > > If varSearch = "" Then Exit Sub
> > >
> > > With ws1.Columns("G")
> > > Set varFound = .Find(varSearch, LookIn:=xlValues, LookAt:=xlWhole)
> > > If Not varFound Is Nothing Then
> > > strAddress = varFound.Address
> > > Do
> > > lngLastRow = ws2.Cells(Rows.Count, "G").End(xlUp).Row + 1
> > > ws1.Rows(varFound.Row).Copy ws2.Rows(lngLastRow)
> > > Set varFound = .FindNext(varFound)
> > > Loop While Not varFound Is Nothing And _
> > > varFound.Address <> strAddress
> > > End If
> > > End With
> > > End Sub
> > >
> > > --
> > > Jacob (MVP - Excel)
> > >
> > >
> > > "climate" wrote:
> > >
> > > > Hi
> > > > I have following code for row selecting based on number of column G and copy
> > > > to sheet (winter), but i have 2 problem. 1) for example: when i input 38 to
> > > > box, row with number of 13856 be selected. 2) i need to select multiple row
> > > > for copy to sheet1 not one row.
> > > > Sub CopyRow()
> > > > Dim Answer As String
> > > > Dim LastRowOnwinter As Long
> > > > With Worksheets("sheet1")
> > > > LastRowOnwinter = .Cells(.Rows.Count, "A").End(xlUp).Row
> > > > If LastRowOnwinter = 1 And .Cells(1, "A").Value = "" Then
> > > > LastRowOnwinter = 0
> > > > End If
> > > > Answer = InputBox("Find which number in row G and copy it?")
> > > > Worksheets("winter").Columns("G").Find(Answer).EntireRow. _
> > > > Copy .Range("A" & (LastRowOnwinter + 1))
> > > > End With
> > > > End Sub
> > > >
> > > > Would you please guide me?
> > > > regards

 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      29th Apr 2010
OK>So do you mean the subsequent rows are blank or will it have the same
numbers...If they do have the same numbers then the earlier macro should copy
those too....Its much easier for someone to pick up when you explain with
sample data...

--
Jacob (MVP - Excel)


"climate" wrote:

> Hi
> You are right, yes, i need to copy subsequent rows and maximum 30 rows.
> My expected is When i run your code and open box for row number of column
> G[38,567,1299,4567,...] then related rows copy to sheet2. criteria is values
> in ColG.
>
> Regards
>
> "Jacob Skaria" wrote:
>
> > --The macro copies all rows containing the search value in ColG.
> >
> > --If you mean to copy subsequent rows to the other sheet; then you havent
> > mentioned how many rows to be copied or the criteria to know how many
> > subsequent rows are to be copied.
> >
> > Post back with sample data.
> >
> > --
> > Jacob (MVP - Excel)
> >
> >
> > "climate" wrote:
> >
> > > Hello Jacob
> > > Thank you, but my second problem is exist. i want to select several rows not
> > > one row.
> > > regards
> > >
> > > "Jacob Skaria" wrote:
> > >
> > > > Try the below. Edit the sheet names to suit...
> > > >
> > > > Sub CopyRow()
> > > > Dim ws1 As Worksheet, ws2 As Worksheet
> > > > Dim varFound As Variant, varSearch As Variant
> > > > Dim strAddress As String, lngLastRow As Long
> > > >
> > > > Set ws1 = Sheets("Sheet1") 'source sheet
> > > > Set ws2 = Sheets("Sheet2") 'destination sheet
> > > >
> > > > varSearch = InputBox("Find which number in row G and copy it?")
> > > > If varSearch = "" Then Exit Sub
> > > >
> > > > With ws1.Columns("G")
> > > > Set varFound = .Find(varSearch, LookIn:=xlValues, LookAt:=xlWhole)
> > > > If Not varFound Is Nothing Then
> > > > strAddress = varFound.Address
> > > > Do
> > > > lngLastRow = ws2.Cells(Rows.Count, "G").End(xlUp).Row + 1
> > > > ws1.Rows(varFound.Row).Copy ws2.Rows(lngLastRow)
> > > > Set varFound = .FindNext(varFound)
> > > > Loop While Not varFound Is Nothing And _
> > > > varFound.Address <> strAddress
> > > > End If
> > > > End With
> > > > End Sub
> > > >
> > > > --
> > > > Jacob (MVP - Excel)
> > > >
> > > >
> > > > "climate" wrote:
> > > >
> > > > > Hi
> > > > > I have following code for row selecting based on number of column G and copy
> > > > > to sheet (winter), but i have 2 problem. 1) for example: when i input 38 to
> > > > > box, row with number of 13856 be selected. 2) i need to select multiple row
> > > > > for copy to sheet1 not one row.
> > > > > Sub CopyRow()
> > > > > Dim Answer As String
> > > > > Dim LastRowOnwinter As Long
> > > > > With Worksheets("sheet1")
> > > > > LastRowOnwinter = .Cells(.Rows.Count, "A").End(xlUp).Row
> > > > > If LastRowOnwinter = 1 And .Cells(1, "A").Value = "" Then
> > > > > LastRowOnwinter = 0
> > > > > End If
> > > > > Answer = InputBox("Find which number in row G and copy it?")
> > > > > Worksheets("winter").Columns("G").Find(Answer).EntireRow. _
> > > > > Copy .Range("A" & (LastRowOnwinter + 1))
> > > > > End With
> > > > > End Sub
> > > > >
> > > > > Would you please guide me?
> > > > > regards

 
Reply With Quote
 
climate
Guest
Posts: n/a
 
      29th Apr 2010
No, any cell of column G has special value and not repeated.
I need to a macro similar to earlier but with capability of several rows
selecting.
If my desciption is not sufficient, please tell me how can i send sample data.

regards

"Jacob Skaria" wrote:

> OK>So do you mean the subsequent rows are blank or will it have the same
> numbers...If they do have the same numbers then the earlier macro should copy
> those too....Its much easier for someone to pick up when you explain with
> sample data...
>
> --
> Jacob (MVP - Excel)
>
>
> "climate" wrote:
>
> > Hi
> > You are right, yes, i need to copy subsequent rows and maximum 30 rows.
> > My expected is When i run your code and open box for row number of column
> > G[38,567,1299,4567,...] then related rows copy to sheet2. criteria is values
> > in ColG.
> >
> > Regards
> >
> > "Jacob Skaria" wrote:
> >
> > > --The macro copies all rows containing the search value in ColG.
> > >
> > > --If you mean to copy subsequent rows to the other sheet; then you havent
> > > mentioned how many rows to be copied or the criteria to know how many
> > > subsequent rows are to be copied.
> > >
> > > Post back with sample data.
> > >
> > > --
> > > Jacob (MVP - Excel)
> > >
> > >
> > > "climate" wrote:
> > >
> > > > Hello Jacob
> > > > Thank you, but my second problem is exist. i want to select several rows not
> > > > one row.
> > > > regards
> > > >
> > > > "Jacob Skaria" wrote:
> > > >
> > > > > Try the below. Edit the sheet names to suit...
> > > > >
> > > > > Sub CopyRow()
> > > > > Dim ws1 As Worksheet, ws2 As Worksheet
> > > > > Dim varFound As Variant, varSearch As Variant
> > > > > Dim strAddress As String, lngLastRow As Long
> > > > >
> > > > > Set ws1 = Sheets("Sheet1") 'source sheet
> > > > > Set ws2 = Sheets("Sheet2") 'destination sheet
> > > > >
> > > > > varSearch = InputBox("Find which number in row G and copy it?")
> > > > > If varSearch = "" Then Exit Sub
> > > > >
> > > > > With ws1.Columns("G")
> > > > > Set varFound = .Find(varSearch, LookIn:=xlValues, LookAt:=xlWhole)
> > > > > If Not varFound Is Nothing Then
> > > > > strAddress = varFound.Address
> > > > > Do
> > > > > lngLastRow = ws2.Cells(Rows.Count, "G").End(xlUp).Row + 1
> > > > > ws1.Rows(varFound.Row).Copy ws2.Rows(lngLastRow)
> > > > > Set varFound = .FindNext(varFound)
> > > > > Loop While Not varFound Is Nothing And _
> > > > > varFound.Address <> strAddress
> > > > > End If
> > > > > End With
> > > > > End Sub
> > > > >
> > > > > --
> > > > > Jacob (MVP - Excel)
> > > > >
> > > > >
> > > > > "climate" wrote:
> > > > >
> > > > > > Hi
> > > > > > I have following code for row selecting based on number of column G and copy
> > > > > > to sheet (winter), but i have 2 problem. 1) for example: when i input 38 to
> > > > > > box, row with number of 13856 be selected. 2) i need to select multiple row
> > > > > > for copy to sheet1 not one row.
> > > > > > Sub CopyRow()
> > > > > > Dim Answer As String
> > > > > > Dim LastRowOnwinter As Long
> > > > > > With Worksheets("sheet1")
> > > > > > LastRowOnwinter = .Cells(.Rows.Count, "A").End(xlUp).Row
> > > > > > If LastRowOnwinter = 1 And .Cells(1, "A").Value = "" Then
> > > > > > LastRowOnwinter = 0
> > > > > > End If
> > > > > > Answer = InputBox("Find which number in row G and copy it?")
> > > > > > Worksheets("winter").Columns("G").Find(Answer).EntireRow. _
> > > > > > Copy .Range("A" & (LastRowOnwinter + 1))
> > > > > > End With
> > > > > > End Sub
> > > > > >
> > > > > > Would you please guide me?
> > > > > > regards

 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      29th Apr 2010
Post sample data of Col G...
--
Jacob (MVP - Excel)


"climate" wrote:

> No, any cell of column G has special value and not repeated.
> I need to a macro similar to earlier but with capability of several rows
> selecting.
> If my desciption is not sufficient, please tell me how can i send sample data.
>
> regards
>
> "Jacob Skaria" wrote:
>
> > OK>So do you mean the subsequent rows are blank or will it have the same
> > numbers...If they do have the same numbers then the earlier macro should copy
> > those too....Its much easier for someone to pick up when you explain with
> > sample data...
> >
> > --
> > Jacob (MVP - Excel)
> >
> >
> > "climate" wrote:
> >
> > > Hi
> > > You are right, yes, i need to copy subsequent rows and maximum 30 rows.
> > > My expected is When i run your code and open box for row number of column
> > > G[38,567,1299,4567,...] then related rows copy to sheet2. criteria is values
> > > in ColG.
> > >
> > > Regards
> > >
> > > "Jacob Skaria" wrote:
> > >
> > > > --The macro copies all rows containing the search value in ColG.
> > > >
> > > > --If you mean to copy subsequent rows to the other sheet; then you havent
> > > > mentioned how many rows to be copied or the criteria to know how many
> > > > subsequent rows are to be copied.
> > > >
> > > > Post back with sample data.
> > > >
> > > > --
> > > > Jacob (MVP - Excel)
> > > >
> > > >
> > > > "climate" wrote:
> > > >
> > > > > Hello Jacob
> > > > > Thank you, but my second problem is exist. i want to select several rows not
> > > > > one row.
> > > > > regards
> > > > >
> > > > > "Jacob Skaria" wrote:
> > > > >
> > > > > > Try the below. Edit the sheet names to suit...
> > > > > >
> > > > > > Sub CopyRow()
> > > > > > Dim ws1 As Worksheet, ws2 As Worksheet
> > > > > > Dim varFound As Variant, varSearch As Variant
> > > > > > Dim strAddress As String, lngLastRow As Long
> > > > > >
> > > > > > Set ws1 = Sheets("Sheet1") 'source sheet
> > > > > > Set ws2 = Sheets("Sheet2") 'destination sheet
> > > > > >
> > > > > > varSearch = InputBox("Find which number in row G and copy it?")
> > > > > > If varSearch = "" Then Exit Sub
> > > > > >
> > > > > > With ws1.Columns("G")
> > > > > > Set varFound = .Find(varSearch, LookIn:=xlValues, LookAt:=xlWhole)
> > > > > > If Not varFound Is Nothing Then
> > > > > > strAddress = varFound.Address
> > > > > > Do
> > > > > > lngLastRow = ws2.Cells(Rows.Count, "G").End(xlUp).Row + 1
> > > > > > ws1.Rows(varFound.Row).Copy ws2.Rows(lngLastRow)
> > > > > > Set varFound = .FindNext(varFound)
> > > > > > Loop While Not varFound Is Nothing And _
> > > > > > varFound.Address <> strAddress
> > > > > > End If
> > > > > > End With
> > > > > > End Sub
> > > > > >
> > > > > > --
> > > > > > Jacob (MVP - Excel)
> > > > > >
> > > > > >
> > > > > > "climate" wrote:
> > > > > >
> > > > > > > Hi
> > > > > > > I have following code for row selecting based on number of column G and copy
> > > > > > > to sheet (winter), but i have 2 problem. 1) for example: when i input 38 to
> > > > > > > box, row with number of 13856 be selected. 2) i need to select multiple row
> > > > > > > for copy to sheet1 not one row.
> > > > > > > Sub CopyRow()
> > > > > > > Dim Answer As String
> > > > > > > Dim LastRowOnwinter As Long
> > > > > > > With Worksheets("sheet1")
> > > > > > > LastRowOnwinter = .Cells(.Rows.Count, "A").End(xlUp).Row
> > > > > > > If LastRowOnwinter = 1 And .Cells(1, "A").Value = "" Then
> > > > > > > LastRowOnwinter = 0
> > > > > > > End If
> > > > > > > Answer = InputBox("Find which number in row G and copy it?")
> > > > > > > Worksheets("winter").Columns("G").Find(Answer).EntireRow. _
> > > > > > > Copy .Range("A" & (LastRowOnwinter + 1))
> > > > > > > End With
> > > > > > > End Sub
> > > > > > >
> > > > > > > Would you please guide me?
> > > > > > > regards

 
Reply With Quote
 
climate
Guest
Posts: n/a
 
      30th Apr 2010
Hi
Column G consist of 4000 cell (1 to 4000 value) which their values
distributed irregular, for example(G2= 25 ........ G4000=17).
Please send me your e-mail if above my describtion not sufficient , to send
my colG.

regards

"Jacob Skaria" wrote:

> Post sample data of Col G...
> --
> Jacob (MVP - Excel)
>
>
> "climate" wrote:
>
> > No, any cell of column G has special value and not repeated.
> > I need to a macro similar to earlier but with capability of several rows
> > selecting.
> > If my desciption is not sufficient, please tell me how can i send sample data.
> >
> > regards
> >
> > "Jacob Skaria" wrote:
> >
> > > OK>So do you mean the subsequent rows are blank or will it have the same
> > > numbers...If they do have the same numbers then the earlier macro should copy
> > > those too....Its much easier for someone to pick up when you explain with
> > > sample data...
> > >
> > > --
> > > Jacob (MVP - Excel)
> > >
> > >
> > > "climate" wrote:
> > >
> > > > Hi
> > > > You are right, yes, i need to copy subsequent rows and maximum 30 rows.
> > > > My expected is When i run your code and open box for row number of column
> > > > G[38,567,1299,4567,...] then related rows copy to sheet2. criteria is values
> > > > in ColG.
> > > >
> > > > Regards
> > > >
> > > > "Jacob Skaria" wrote:
> > > >
> > > > > --The macro copies all rows containing the search value in ColG.
> > > > >
> > > > > --If you mean to copy subsequent rows to the other sheet; then you havent
> > > > > mentioned how many rows to be copied or the criteria to know how many
> > > > > subsequent rows are to be copied.
> > > > >
> > > > > Post back with sample data.
> > > > >
> > > > > --
> > > > > Jacob (MVP - Excel)
> > > > >
> > > > >
> > > > > "climate" wrote:
> > > > >
> > > > > > Hello Jacob
> > > > > > Thank you, but my second problem is exist. i want to select several rows not
> > > > > > one row.
> > > > > > regards
> > > > > >
> > > > > > "Jacob Skaria" wrote:
> > > > > >
> > > > > > > Try the below. Edit the sheet names to suit...
> > > > > > >
> > > > > > > Sub CopyRow()
> > > > > > > Dim ws1 As Worksheet, ws2 As Worksheet
> > > > > > > Dim varFound As Variant, varSearch As Variant
> > > > > > > Dim strAddress As String, lngLastRow As Long
> > > > > > >
> > > > > > > Set ws1 = Sheets("Sheet1") 'source sheet
> > > > > > > Set ws2 = Sheets("Sheet2") 'destination sheet
> > > > > > >
> > > > > > > varSearch = InputBox("Find which number in row G and copy it?")
> > > > > > > If varSearch = "" Then Exit Sub
> > > > > > >
> > > > > > > With ws1.Columns("G")
> > > > > > > Set varFound = .Find(varSearch, LookIn:=xlValues, LookAt:=xlWhole)
> > > > > > > If Not varFound Is Nothing Then
> > > > > > > strAddress = varFound.Address
> > > > > > > Do
> > > > > > > lngLastRow = ws2.Cells(Rows.Count, "G").End(xlUp).Row + 1
> > > > > > > ws1.Rows(varFound.Row).Copy ws2.Rows(lngLastRow)
> > > > > > > Set varFound = .FindNext(varFound)
> > > > > > > Loop While Not varFound Is Nothing And _
> > > > > > > varFound.Address <> strAddress
> > > > > > > End If
> > > > > > > End With
> > > > > > > End Sub
> > > > > > >
> > > > > > > --
> > > > > > > Jacob (MVP - Excel)
> > > > > > >
> > > > > > >
> > > > > > > "climate" wrote:
> > > > > > >
> > > > > > > > Hi
> > > > > > > > I have following code for row selecting based on number of column G and copy
> > > > > > > > to sheet (winter), but i have 2 problem. 1) for example: when i input 38 to
> > > > > > > > box, row with number of 13856 be selected. 2) i need to select multiple row
> > > > > > > > for copy to sheet1 not one row.
> > > > > > > > Sub CopyRow()
> > > > > > > > Dim Answer As String
> > > > > > > > Dim LastRowOnwinter As Long
> > > > > > > > With Worksheets("sheet1")
> > > > > > > > LastRowOnwinter = .Cells(.Rows.Count, "A").End(xlUp).Row
> > > > > > > > If LastRowOnwinter = 1 And .Cells(1, "A").Value = "" Then
> > > > > > > > LastRowOnwinter = 0
> > > > > > > > End If
> > > > > > > > Answer = InputBox("Find which number in row G and copy it?")
> > > > > > > > Worksheets("winter").Columns("G").Find(Answer).EntireRow. _
> > > > > > > > Copy .Range("A" & (LastRowOnwinter + 1))
> > > > > > > > End With
> > > > > > > > End Sub
> > > > > > > >
> > > > > > > > Would you please guide me?
> > > > > > > > regards

 
Reply With Quote
 
climate
Guest
Posts: n/a
 
      1st May 2010
Hello Jacob
How can i Post sample data of Col G...?
regards

"Jacob Skaria" wrote:

> Post sample data of Col G...
> --
> Jacob (MVP - Excel)
>
>
> "climate" wrote:
>
> > No, any cell of column G has special value and not repeated.
> > I need to a macro similar to earlier but with capability of several rows
> > selecting.
> > If my desciption is not sufficient, please tell me how can i send sample data.
> >
> > regards
> >
> > "Jacob Skaria" wrote:
> >
> > > OK>So do you mean the subsequent rows are blank or will it have the same
> > > numbers...If they do have the same numbers then the earlier macro should copy
> > > those too....Its much easier for someone to pick up when you explain with
> > > sample data...
> > >
> > > --
> > > Jacob (MVP - Excel)
> > >
> > >
> > > "climate" wrote:
> > >
> > > > Hi
> > > > You are right, yes, i need to copy subsequent rows and maximum 30 rows.
> > > > My expected is When i run your code and open box for row number of column
> > > > G[38,567,1299,4567,...] then related rows copy to sheet2. criteria is values
> > > > in ColG.
> > > >
> > > > Regards
> > > >
> > > > "Jacob Skaria" wrote:
> > > >
> > > > > --The macro copies all rows containing the search value in ColG.
> > > > >
> > > > > --If you mean to copy subsequent rows to the other sheet; then you havent
> > > > > mentioned how many rows to be copied or the criteria to know how many
> > > > > subsequent rows are to be copied.
> > > > >
> > > > > Post back with sample data.
> > > > >
> > > > > --
> > > > > Jacob (MVP - Excel)
> > > > >
> > > > >
> > > > > "climate" wrote:
> > > > >
> > > > > > Hello Jacob
> > > > > > Thank you, but my second problem is exist. i want to select several rows not
> > > > > > one row.
> > > > > > regards
> > > > > >
> > > > > > "Jacob Skaria" wrote:
> > > > > >
> > > > > > > Try the below. Edit the sheet names to suit...
> > > > > > >
> > > > > > > Sub CopyRow()
> > > > > > > Dim ws1 As Worksheet, ws2 As Worksheet
> > > > > > > Dim varFound As Variant, varSearch As Variant
> > > > > > > Dim strAddress As String, lngLastRow As Long
> > > > > > >
> > > > > > > Set ws1 = Sheets("Sheet1") 'source sheet
> > > > > > > Set ws2 = Sheets("Sheet2") 'destination sheet
> > > > > > >
> > > > > > > varSearch = InputBox("Find which number in row G and copy it?")
> > > > > > > If varSearch = "" Then Exit Sub
> > > > > > >
> > > > > > > With ws1.Columns("G")
> > > > > > > Set varFound = .Find(varSearch, LookIn:=xlValues, LookAt:=xlWhole)
> > > > > > > If Not varFound Is Nothing Then
> > > > > > > strAddress = varFound.Address
> > > > > > > Do
> > > > > > > lngLastRow = ws2.Cells(Rows.Count, "G").End(xlUp).Row + 1
> > > > > > > ws1.Rows(varFound.Row).Copy ws2.Rows(lngLastRow)
> > > > > > > Set varFound = .FindNext(varFound)
> > > > > > > Loop While Not varFound Is Nothing And _
> > > > > > > varFound.Address <> strAddress
> > > > > > > End If
> > > > > > > End With
> > > > > > > End Sub
> > > > > > >
> > > > > > > --
> > > > > > > Jacob (MVP - Excel)
> > > > > > >
> > > > > > >
> > > > > > > "climate" wrote:
> > > > > > >
> > > > > > > > Hi
> > > > > > > > I have following code for row selecting based on number of column G and copy
> > > > > > > > to sheet (winter), but i have 2 problem. 1) for example: when i input 38 to
> > > > > > > > box, row with number of 13856 be selected. 2) i need to select multiple row
> > > > > > > > for copy to sheet1 not one row.
> > > > > > > > Sub CopyRow()
> > > > > > > > Dim Answer As String
> > > > > > > > Dim LastRowOnwinter As Long
> > > > > > > > With Worksheets("sheet1")
> > > > > > > > LastRowOnwinter = .Cells(.Rows.Count, "A").End(xlUp).Row
> > > > > > > > If LastRowOnwinter = 1 And .Cells(1, "A").Value = "" Then
> > > > > > > > LastRowOnwinter = 0
> > > > > > > > End If
> > > > > > > > Answer = InputBox("Find which number in row G and copy it?")
> > > > > > > > Worksheets("winter").Columns("G").Find(Answer).EntireRow. _
> > > > > > > > Copy .Range("A" & (LastRowOnwinter + 1))
> > > > > > > > End With
> > > > > > > > End Sub
> > > > > > > >
> > > > > > > > Would you please guide me?
> > > > > > > > regards

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy rows to multiple sheets pvkutty Microsoft Excel Misc 1 24th Feb 2010 07:25 AM
copy multiple rows from a database =?Utf-8?B?YnJhZGFzbGV5?= Microsoft Excel Programming 1 13th Feb 2006 04:10 PM
copy multiple rows =?Utf-8?B?RGlhbm5h?= Microsoft Excel Misc 2 8th Nov 2004 10:34 PM
Copy 1 Row to Multiple Rows =?Utf-8?B?Rm9Nb0NvLVRvbQ==?= Microsoft Excel Misc 4 8th Jun 2004 03:47 PM
copy rows from multiple worksheets paul mueller Microsoft Excel Programming 1 24th Mar 2004 09:28 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:28 AM.