+ Reply to Thread
Results 1 to 3 of 3

VBA Question - Run this code on another column

  1. #1
    Scott Wagner
    Guest

    VBA Question - Run this code on another column

    The following code was provided to me by Tom Ogilvy.

    Currently it runs against column C, and I need it to run on column F
    instead. I tried experimenting with it to work it out but am getting nowhere
    fast.

    Can you help?

    Thanks in advance.

    Scott

    Code:

    Dim rng2 As Range, cell2 As Range, iloc As Long
    Set rng2 = Range(Cells(2, 3), Cells(Rows.Count, 3).End(xlUp))
    For Each cell2 In rng2
    iloc = InStr(1, cell2, " ", vbTextCompare)
    If iloc <> 0 Then
    cell2.Offset(0, 1).Value = Mid(cell2.Value, iloc + 1, 255)
    cell2.Value = Mid(cell2, 1, iloc - 1)
    End If
    Next

  2. #2
    Ron de Bruin
    Guest

    Re: VBA Question - Run this code on another column

    Hi Scott

    Cells(row,column)

    Tom used 3 for column C

    Range(Cells(2, 3), Cells(Rows.Count, 3).End(xlUp))

    Change the 3 to 6 for F

    --
    Regards Ron de Bruin
    http://www.rondebruin.nl


    "Scott Wagner" <[email protected]> wrote in message news:[email protected]...
    > The following code was provided to me by Tom Ogilvy.
    >
    > Currently it runs against column C, and I need it to run on column F
    > instead. I tried experimenting with it to work it out but am getting nowhere
    > fast.
    >
    > Can you help?
    >
    > Thanks in advance.
    >
    > Scott
    >
    > Code:
    >
    > Dim rng2 As Range, cell2 As Range, iloc As Long
    > Set rng2 = Range(Cells(2, 3), Cells(Rows.Count, 3).End(xlUp))
    > For Each cell2 In rng2
    > iloc = InStr(1, cell2, " ", vbTextCompare)
    > If iloc <> 0 Then
    > cell2.Offset(0, 1).Value = Mid(cell2.Value, iloc + 1, 255)
    > cell2.Value = Mid(cell2, 1, iloc - 1)
    > End If
    > Next




  3. #3
    Scott Wagner
    Guest

    Re: VBA Question - Run this code on another column

    Ron,

    Thanks for the quick response, and the detailed information.

    I was trying to change one or the other... didn't think to change both.

    DOUGH!

    Thanks,

    Scott

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1