ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Problem in macro (https://www.excelbanter.com/excel-discussion-misc-queries/73417-problem-macro.html)

Micos3

Problem in macro
 
I got this macro that all the letters "K" that are printed in row B, send to
sheet2 by order all the line of that letter starting in row B.

What i want is to limit the rows that are copy to sheet2, cos in Macro in
sheet1 i copy all the rows after row "C", to sheet2, but i want to limit the
copy since "C" to row "G", can anyone help me?

Thanks

Sub comlin4()
Dim i As Long
Dim nextrow As Long

With ActiveSheet
For i = 2 To .Cells(.Rows.Count, "B").End(xlUp).Row
If .Cells(i, "B").Value = "K" Then
With Worksheets("Folha2")
nextrow = .Cells(.Rows.Count, "B").End(xlUp).Row + 1
End With
.Cells(i, "C").Resize(, 10).Copy Worksheets("Folha2").Range("B"
& nextrow)
End If
Next i
End With

End Sub

Bernie Deitrick

Problem in macro
 
Micos,

Change

Resize(, 10)

to

Resize(, 5)

HTH,
Bernie
MS Excel MVP


"Micos3" wrote in message
...
I got this macro that all the letters "K" that are printed in row B, send to
sheet2 by order all the line of that letter starting in row B.

What i want is to limit the rows that are copy to sheet2, cos in Macro in
sheet1 i copy all the rows after row "C", to sheet2, but i want to limit the
copy since "C" to row "G", can anyone help me?

Thanks

Sub comlin4()
Dim i As Long
Dim nextrow As Long

With ActiveSheet
For i = 2 To .Cells(.Rows.Count, "B").End(xlUp).Row
If .Cells(i, "B").Value = "K" Then
With Worksheets("Folha2")
nextrow = .Cells(.Rows.Count, "B").End(xlUp).Row + 1
End With
.Cells(i, "C").Resize(, 10).Copy Worksheets("Folha2").Range("B"
& nextrow)
End If
Next i
End With

End Sub




Micos3

Problem in macro
 
I tryed before to change that number in resize, but once i didn't knew what
could i do, i change and it didn't gave the same result, but now worked just
fine, and now i can see the light. :D


Many thanks



All times are GMT +1. The time now is 07:09 AM.

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