Consulting

Results 1 to 4 of 4

Thread: excel_copy

  1. #1
    VBAX Tutor
    Joined
    Dec 2009
    Posts
    295
    Location

    excel_copy

    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


    Thanks

  2. #2
    VBAX Mentor
    Joined
    Jun 2004
    Posts
    363
    Location
    [VBA]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[/VBA]

  3. #3
    VBAX Tutor
    Joined
    Dec 2009
    Posts
    295
    Location
    hi
    thanks
    how can i see in the macro the column A or B?

  4. #4
    VBAX Mentor
    Joined
    Jun 2004
    Posts
    363
    Location
    Quote Originally Posted by oleg_v
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •