+ Reply to Thread
Results 1 to 4 of 4

retrieve text from merged cells-How do i read the text in the merged cell?

  1. #1
    Eric
    Guest

    retrieve text from merged cells-How do i read the text in the merged cell?

    I have several cells in a single column merged into one cell.
    Before merging the top cell had text and the other cells in the "to be"
    merged area had no text. Then i merged them. ok so far.
    Now i have a macro that iterates down the rows. some rows are ordinary rows
    and in some places they are part of a merged area (in a single column)

    My question is: How do i read the text in the merged cell?

    str = Cells.Item(mRow, mCol).Value sometimes produces str==""
    when it hits a row that contains part of a merged cell

    str = Cells.Item(mRow, mCol).MergedCells.Text is the kind of thing i need.
    How do you do that?

    Thanks
    Eric

  2. #2
    David McRitchie
    Guest

    re: retrieve text from merged cells-How do i read the text in the merged cell?

    Hi Eric,
    Once a cell is merged the parts that you do no see no longer exists,
    only the content of the upper left cell of the merged cell survives.

    So I'm not sure what the question is. If you want to see how I
    handle merged cells in converting an Excel selection to an
    HTML table see http://www.mvps.org/dmcritchie/excel/code/xl2htmlx.txt
    ---
    HTH,
    David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
    My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
    Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

    "Eric" <BorgMotherShip@AliensR_US.org> wrote in message news:[email protected]...
    > I have several cells in a single column merged into one cell.
    > Before merging the top cell had text and the other cells in the "to be"
    > merged area had no text. Then i merged them. ok so far.
    > Now i have a macro that iterates down the rows. some rows are ordinary rows
    > and in some places they are part of a merged area (in a single column)
    >
    > My question is: How do i read the text in the merged cell?
    >
    > str = Cells.Item(mRow, mCol).Value sometimes produces str==""
    > when it hits a row that contains part of a merged cell
    >
    > str = Cells.Item(mRow, mCol).MergedCells.Text is the kind of thing i need.
    > How do you do that?
    >
    > Thanks
    > Eric




  3. #3
    Eric
    Guest

    re: retrieve text from merged cells-How do i read the text in the merged cell?

    David McRitchie wrote:

    > Hi Eric,
    > Once a cell is merged the parts that you do no see no longer exists,
    > only the content of the upper left cell of the merged cell survives.
    >
    > So I'm not sure what the question is. If you want to see how I
    > handle merged cells in converting an Excel selection to an
    > HTML table see http://www.mvps.org/dmcritchie/excel/code/xl2htmlx.txt
    > ---
    > HTH,
    > David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
    > My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
    > Search Page: http://www.mvps.org/dmcritchie/excel/search.htm
    >
    > "Eric" <BorgMotherShip@AliensR_US.org> wrote in message
    > news:[email protected]...
    >> I have several cells in a single column merged into one cell.
    >> Before merging the top cell had text and the other cells in the "to be"
    >> merged area had no text. Then i merged them. ok so far.
    >> Now i have a macro that iterates down the rows. some rows are ordinary
    >> rows and in some places they are part of a merged area (in a single
    >> column)
    >>
    >> My question is: How do i read the text in the merged cell?
    >>
    >> str = Cells.Item(mRow, mCol).Value sometimes produces str==""
    >> when it hits a row that contains part of a merged cell
    >>
    >> str = Cells.Item(mRow, mCol).MergedCells.Text is the kind of thing i
    >> need. How do you do that?
    >>
    >> Thanks
    >> Eric


    so "Cells(r, c).MergeArea.Cells(1).Value" would get the text from a column
    of 5 cells where the top of that column had text typed in the cell and all
    5 cells were merged? if the merge area is row 5 to 10 in column 2 then
    Cells(5, 2).MergeArea.Cells(1).Value
    Cells(6, 2).MergeArea.Cells(1).Value
    Cells(7, 2).MergeArea.Cells(1).Value
    Cells(8, 2).MergeArea.Cells(1).Value
    Cells(9, 2).MergeArea.Cells(1).Value
    Cells(10, 2).MergeArea.Cells(1).Value

    would get the merged area text and not a "" value?
    It seems to work, but I've only given it a superfical testing
    Thanks
    Eric

  4. #4
    David McRitchie
    Guest

    re: retrieve text from merged cells-How do i read the text in the merged cell?

    Hi Eric,
    I expect that if you need the information, you will manage to pry it
    out of the examples, by making your own little tests.

    "Eric" <BorgMotherShip@AliensR_US.org> wrote
    > would get the merged area text and not a "" value?
    > It seems to work, but I've only given it a superfical testing
    > Thanks
    > Eric




+ 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