+ Reply to Thread
Results 1 to 5 of 5

Why a code that works for a sheet does not work for all?

  1. #1
    Registered User
    Join Date
    01-27-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2007
    Posts
    75

    Post Why a code that works for a sheet does not work for all?

    Imagine we have this table:

    http://3.bp.blogspot.com/_gKAnDYGZZUo/TSxxkuHOvUI/AAAAAAAAACc/_mg0dGSoBEg/s1600/example.JPG

    Then, we want create a new line between 34 and 35. The new A35 needs to be merged with A30 and A34, because this new property is a "General Properties", not a "properties".

    The title "General Properties" is chosen in a combobox; the new value (Clients M, Clients C, Total, etc) is given by a textbox, for example, we want write: "new total".

    I created this code to do it to one sheet, that's ok, see:
    (where busca is the address of "General Property")
    Please Login or Register  to view this content.
    However, when I try to put it inside all my code, It doesn't work to all sheets. Instead of it, it just merged from A30 to A38, deleting "properties". What's wrong?

    Please Login or Register  to view this content.
    Last edited by marlonsaveri; 05-31-2011 at 12:30 PM.

  2. #2
    Valued Forum Contributor mohd9876's Avatar
    Join Date
    05-04-2011
    Location
    Amman, Jordan
    MS-Off Ver
    Excel 2010
    Posts
    426

    Re: Why a code that works for a sheet does not work for all?

    try changing this line:
    Please Login or Register  to view this content.
    to this see the line in bold:
    Please Login or Register  to view this content.

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Why a code that works for a sheet does not work for all?

    It's a bad idea to merge cells.

    Try adding an example workbook instead of a link to an image, which doesn't appear to work
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Why a code that works for a sheet does not work for all?

    I agree with Roy: VBA can't cope with merged ranges.
    I do not know what tipo contains

    Please Login or Register  to view this content.
    Last edited by snb; 05-31-2011 at 12:33 PM.



  5. #5
    Registered User
    Join Date
    01-27-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2007
    Posts
    75

    Smile Re: Why a code that works for a sheet does not work for all?

    Thanks guys, I think that's really the error: I forgot "worksheets(i)" after cells() (Or sh)
    tipo was the word in column A.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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