+ Reply to Thread
Results 1 to 2 of 2

cell.formula fails

  1. #1
    Garry
    Guest

    cell.formula fails

    Hi All:

    I'm transforming some Excel data into Word tables. I'm quite familiar
    with Word VBA but having some difficulty with Excel. (This inexperience
    may explain why I feel Excel's VB is flakier than Word's.)

    One problem I've just encountered is this test:

    for each acell in myrange.cells
    if acell.formula="" then acell.value = " "
    next acell

    That is, empty cells have a blank inserted in them. I do this because
    if you copy a range from Excel to Word, empty cells are omitted from
    the Word table, leading to a real mess.

    The comparison fails with a 1004 error after some time. Examination of
    the cell shows it contains about 20 lines of text, otherwise
    unremarkable.

    Any suggestions?
    Garry


  2. #2
    Tom Ogilvy
    Guest

    Re: cell.formula fails

    Dim rng as Range
    On Error Resume Next
    set rng = myrange.SpecialCells(xlBlanks")
    On Error goto 0
    if not rng is nothing then
    rng.Value = " "
    End if

    --
    Regards,
    Tom Ogilvy


    "Garry" <[email protected]> wrote in message
    news:[email protected]...
    > Hi All:
    >
    > I'm transforming some Excel data into Word tables. I'm quite familiar
    > with Word VBA but having some difficulty with Excel. (This inexperience
    > may explain why I feel Excel's VB is flakier than Word's.)
    >
    > One problem I've just encountered is this test:
    >
    > for each acell in myrange.cells
    > if acell.formula="" then acell.value = " "
    > next acell
    >
    > That is, empty cells have a blank inserted in them. I do this because
    > if you copy a range from Excel to Word, empty cells are omitted from
    > the Word table, leading to a real mess.
    >
    > The comparison fails with a 1004 error after some time. Examination of
    > the cell shows it contains about 20 lines of text, otherwise
    > unremarkable.
    >
    > Any suggestions?
    > Garry
    >




+ 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