#1   Report Post  
Posted to microsoft.public.excel.misc
Micos3
 
Posts: n/a
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.misc
Bernie Deitrick
 
Posts: n/a
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.misc
Micos3
 
Posts: n/a
Default 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

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
Macro Help In Excel welshlad Excel Discussion (Misc queries) 14 October 26th 05 02:34 PM
deleting a macro resulted in a problem militant Excel Discussion (Misc queries) 0 April 26th 05 05:21 AM
External data Macro Problem Excel 97 Craig Kelly Excel Discussion (Misc queries) 1 January 17th 05 03:17 PM
Problem executing a macro from different workbook where it is Sergio Calleja Excel Discussion (Misc queries) 1 January 17th 05 12:38 PM
macro problem Kevin Excel Discussion (Misc queries) 1 December 14th 04 10:47 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"