PDA

View Full Version : excel_copy



oleg_v
01-05-2010, 07:23 AM
Hello

I am stuck and i need help with a macro that will do:

1) check column B in sheet1 and if the cell contain the word "dim"
copy the containment of the cell to sheet2 started in A2

:dunno
Thanks

mbarron
01-05-2010, 07:39 AM
Sub copyDim()
Dim i As Long, sh1 As Worksheet, sh2 As Worksheet
Set sh1 = Sheets(1)
Set sh2 = Sheets(2)
i = 2
Do Until sh1.Cells(i, 2) = ""
If InStr(UCase(sh1.Cells(i, 2)), "DIM") > 0 Then
sh1.Cells(i, 2).Copy _
Destination:=sh2.Cells(Rows.Count, 1).End(xlUp).Offset(1)
End If
i = i + 1
Loop
End Sub

oleg_v
01-05-2010, 07:48 AM
hi
thanks
how can i see in the macro the column A or B?

mbarron
01-05-2010, 07:53 AM
hi
thanks
how can i see in the macro the column A or B?
The Cells function uses the Format of:
Cells(Row#,Column#)

The macro is looking for the "dim" in sh1.Cells(i,2) or column #2 (column B) of sheet 1, while the destination is sh2.Cells(first blank row,1) or column #1 (column A) of sheet 2