+ Reply to Thread
Results 1 to 2 of 2

Adding additional rows in VBA based on character strings

Hybrid View

  1. #1
    Mike
    Guest

    Adding additional rows in VBA based on character strings

    Hi all,

    I'm trying to write some VBA code that will allow me to evaluate cells, find
    cells that include "#" somewhere in the string and duplicate the entry and
    modify the "#" to become a symbol. Here's an example.

    A list of items:

    Monkeys
    Cinnamon
    My#Number
    Dogs

    Would become:

    Monkeys
    Cinnamon
    My1Number
    My2Number
    Dogs

    I tried using the replace function, but I'm not having much luck with it.

    Any help would be greatly appreciated,

    Thanks in advance,

    Mike

  2. #2
    Tom Ogilvy
    Guest

    Re: Adding additional rows in VBA based on character strings

    Sub DoctorData()
    Dim i as long, cell as Range
    i = 1
    for each cell in selection
    if instr(cell.Text,"#") then
    cell.Value = application.Substitute(cell.Text,"#",i)
    i = i + 1
    end if
    Next
    End Sub


    --
    Regards,
    Tom Ogilvy

    "Mike" <[email protected]> wrote in message
    news:[email protected]...
    > Hi all,
    >
    > I'm trying to write some VBA code that will allow me to evaluate cells,

    find
    > cells that include "#" somewhere in the string and duplicate the entry and
    > modify the "#" to become a symbol. Here's an example.
    >
    > A list of items:
    >
    > Monkeys
    > Cinnamon
    > My#Number
    > Dogs
    >
    > Would become:
    >
    > Monkeys
    > Cinnamon
    > My1Number
    > My2Number
    > Dogs
    >
    > I tried using the replace function, but I'm not having much luck with it.
    >
    > Any help would be greatly appreciated,
    >
    > Thanks in advance,
    >
    > Mike




+ 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