![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Feb 2002
Posts: 14
|
Hello..
I have a problem, Excel can’t seem to understand me, I would like to copy Cells (I,”B”) And Cells (I,”C”) and Cells (I,”M”) from one worksheet to another It gives me a type miss match error!!! I am choosing these cells off the value in column “M”. Unless I say that entire rows. Copy. And I don’t want that .. Also I would like them to be all in the same row in the secound sheet This is my code that works Sub Copy() Dim RngDestination As Range Dim i As Integer Set RngDestination = Worksheets("Sheet2").Range("A1") For i = Cells(Rows.Count, "M").End(xlUp).Row To 1 Step -1 If Cells(i, "M").Interior.ColorIndex = -4142 Then Cells(i, "M").EntireRow.Copy Destination:=RngDestination Set RngDestination = RngDestination.Offset(RngDestination.Rows.Count) End If Next i And this is what I am trying to do Sub Copy2() Dim RngDestination As Range Dim i As Integer Set RngDestination = Worksheets("Sheet2").Range("A1") For i = Cells(Rows.Count, "M").End(xlUp).Row To 1 Step -1 If Cells(i, "M").Interior.ColorIndex = -4142 Then Cells((i, "B"),(i,"C")Cells(i,"M")).Copy Destination:=RngDestination Set RngDestination = RngDestination.Offset(RngDestination.Rows.Count) End If Next I Thanks for the help |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Portland, OR USA
Posts: 1,374
|
Change your "M" to 13 - which is the corresponding column number for column M (and "B" to 2, and "C" to 3, etc.).
-rh [ This Message was edited by: Russell Hauf on 2002-02-28 09:19 ] |
|
|
|
|
|
#3 |
|
New Member
Join Date: Feb 2002
Posts: 14
|
it is still giving me the same error
this what i did Cells((i, 2),(i,3)Cells(i,13)).Copy Destination:=RngDestination syntax error... please advice thanks |
|
|
|
|
|
#4 | |
|
Board Regular
Join Date: Feb 2002
Location: Chippenham, UK
Posts: 136
|
Quote:
Try That, _________________ Regards, Gary Hewitt-Long [ This Message was edited by: gplhl on 2002-02-28 11:57 ] |
|
|
|
|
|
|
#5 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Portland, OR USA
Posts: 1,374
|
Quote:
|
|
|
|
|
|
|
#6 |
|
New Member
Join Date: Feb 2002
Posts: 14
|
Thank you both for your responses
The cells that I am trying to copy are Cell (I,”B”) And Cell (I,”C”) And Cell (I,”M”) . where I is an Integer (Row Number) That means three cells in one row …. And till now I can’t make it work L |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|