+ Reply to Thread
Results 1 to 6 of 6

Amount of cells in a range

  1. #1
    Registered User
    Join Date
    11-03-2009
    Location
    Methylane
    MS-Off Ver
    Excel 2003
    Posts
    23

    Amount of cells in a range

    For starters, I'm stuck with merged cells, can't change it

    I need to come up with ways to work around this.
    Say I have a merged area of A1:A*, what I would like to know is how many columns are actually used in this merged area.
    A1:A4 would return 4, A1:A8 would return 8, A1:C8 would return 8 et cetera.

    Now I've played a bit with MergeArea.Address and although it returns me the correct range, I'm stuck with actually using it further.

    Any ideas?
    Last edited by ctor; 11-04-2009 at 08:47 AM. Reason: Solved :)

  2. #2
    Valued Forum Contributor
    Join Date
    07-21-2008
    Location
    London, UK
    Posts
    326

    Re: Amount of cells in a range

    Once you know

    example Cell A is covering A1 - A3 and your returned value = 3

    Then waht do you want to do

    Remember the merged cell will be known as A1 and ccells A2 & A3 will be gone for now

  3. #3
    Valued Forum Contributor
    Join Date
    07-21-2008
    Location
    London, UK
    Posts
    326

    Re: Amount of cells in a range

    Please Login or Register  to view this content.

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

    Re: Amount of cells in a range

    You will find that all experienced VBA coders will tell you to avoid Merged Cells like the plague.

    A range of merged cells becomes one cell & one Column
    Hope that helps.

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

    Free DataBaseForm example

  5. #5
    Registered User
    Join Date
    11-03-2009
    Location
    Methylane
    MS-Off Ver
    Excel 2003
    Posts
    23

    Re: Amount of cells in a range

    MergeArea.Count was exactly what I was looking for
    Cheers...




    If I was able to avoid them, I would, they're the only, single, reason this is taking long. Experienced or not, in some situations you can't avoid working with stuff you'd rather not work with.
    These sheets are generated by some piece of software, over which I have no control. It just happens to contain alot of these merged areas, I have to program my way around it and it's not pretty.

    You can't control other peoples' software and I can't go to the client telling him to **** off with his merged cells. That's just not how the world works
    Especially as I need to pay my mortgage fees every month and feed myself

    What I want to do with it, and this is ugly, is I copy values from some sheet to a sheet displaying information to the user, this display sheet is riddled with merged cells. But the data sheet is 'normal', so I have to copy stuff from the datasheet to the display sheet, but that would give lots of errors because of the merged cells, so i temporary disable the merged cells, paste the data, remerge them (ï've to apply some formatting later) so as not to toy with the original template.
    It's a 2 week project, so I'm bound to get a high blood pressure the coming days

    This is the code (at this moment), it's my first attempt at Excel and/or VBA, so it's probably bad, but it's a work in progress and more of a concept
    Feel free to laugh at its ugliness.


    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    11-11-2009
    Location
    Idaho, USA
    MS-Off Ver
    Office 2000, 2003. 2007
    Posts
    1

    Re: Amount of cells in a range

    Ctor, One thing that I'd suggest for you is to make a copy of the source page, use it as your working page and delete it when you're finished. That eliminates the requirement of restoring all of the merged cells.

+ 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