+ Reply to Thread
Results 1 to 22 of 22

Underlying row height

  1. #1
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Underlying row height

    For once, I respectfully ask that you do not reply to this thread unless you have a definitive YES or NO answer
    - some members do not look at threads which already contain replies - and I would prefer this thread to remain unanswered until someone can give me a categoric YES or NO
    I have a very specific need. I am not looking for a workaround. Removing and re-applying the filter is not an option - the filter is complex (and frequently changing!) and applied manually - capturing those values in VBA to re-apply the data filter each time would require an impressive bit of VBA coding - and I do not want to go down that route.
    thank you


    With data filter applied .RowHeight returns value = 0 in respect of any rows filtered out
    With data filter turned off, the row returns to its previous height - Excel therefore holds all the original values somewhere

    Can VBA return that original value at the moment when the row is filtered out (whilst the workbook is open)?
    (And if so what is the code)
    Last edited by kev_; 04-22-2017 at 04:24 AM.
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  2. #2
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: Underlying row height

    The last line of your signature with a smily encouraged me to ask for an explanation of what you want.
    Teach me Excel VBA

  3. #3
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Underlying row height

    @ImranBhatti How totally unhelpful of you

  4. #4
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,210

    Re: Underlying row height

    Hi kev_

    If I understand your question correctly then this could help... Searches range for hidden row and returns row No and Row Height
    Please Login or Register  to view this content.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  5. #5
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Underlying row height

    @Sintek - no you did not understand the question

    This is an example of what I am trying to achieve:
    Format a row and set its height to 100
    - using VBA .Height and .RowHeight both tell us the height is 100
    Now hide it (or filter it out)
    - using VBA .Height and .RowHeight both tell us the height is now 0
    Unhide the row
    - using VBA gives the the height = 100 again
    - so Excel knows how to re-set the height after its been hidden - Excel does NOT require to be told the 100 - Excel REMEMBERS that value

    What I want is for VBA to tell me the number 100 whilst the row is still hidden
    - it is a waste of time trying to use either .Height or .RowHeight

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,210

    Re: Underlying row height

    Now you've got me wondering as well. My apologies for not understanding. Glad you clarified. Will be searching the web.

  7. #7
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: Underlying row height

    I would prefer this thread to remain unanswered until someone can give me a categoric YES or NO
    I cannot provide a categoric yes/no answer myself, but, since it seems to have gone a little cold, I will proffer this observation and see if it helps get to the categoric yes/no.

    As many know, since at least 2007, xlsx (and other Excel files) are really "zipped" files containing a bunch of xml files. I created a small, simple spreadsheet with a bunch of random numbers, changed the height of a few rows, and filtered them to hide column A values greater than 0.5 then saved and closed. Renamed the file to change the extension from xlsx to zip and unzipped the files, found the xml file for the spreadsheet, then looked to see if "row height" is stored there. Some of the content of that xml file:
    Please Login or Register  to view this content.
    Row 5 is perhaps of most interest here, as you can see that it has a different row height from the default, and it also has the hidden indicator. Compare to row 8 which has a non-default row height, but is not hidden and to the other rows which are all at default row height.

    I have no idea how to access that information from VBA, but I can see that the information is stored in the file and where it is stored in the file. Perhaps that will prompt something towards figuring out how to access the information (or maybe it won't because it is just too impractical to access the xml code of an open file).
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  8. #8
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Underlying row height

    Thank you Mr Shorty
    I want to access this information in the live situation where the data will have been sorted - and so any row numbers previously stored in an xml would be incorrect.
    So what could possibly work would be a dump to xml, extraction of all row heights from xml, immediate use of those values etc. Unfortunately if data is sorted again or row inserted we go back through the same loop.
    But that seems very long-winded if you can get at the value directly.
    it would be so much easier to get at the value directly.
    I am having a separate play with extracting those values using
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    as RefersTo formula in a named range "RowHeight"
    And then using formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    in a cell in each row
    Try it - it works
    - but it appears the values do not change if the row height is changed - it's almost as if the original row height value gets stuck in there.
    I have tried refreshing, and saving the file again. After doing that I entered the formula in a new cell, and it still gives me the previous value - I did not expect that.
    I could use VBA to recreate the formulas on the hoof to get the values if I can get the value to change using the formula in Excel in the first instance.
    So the next step is to close the file and re-open it to see if that gets me anywhere!
    I may start a separate thread on it to see if there is a trick I am missing - but I remember things so much better if I puzzle things out myself - so if you see the thread I will have been defeated!


    EDIT1
    That did not work either
    In sheer desperation I tried it on a clean file - and it works beautifully - but
    I am now off to see if I can break that.....

    EDIT2
    Unfortunately that was not quite what I wanted either -it also changes to zero when row is filtered out
    Next step VBA to "freeze" value at the correct time and then recalc again when row height changes

    NOTE:
    I am still looking for a definitive answer to the question posed at the beginning of this thread
    Last edited by kev_; 04-23-2017 at 03:38 AM.

  9. #9
    Registered User
    Join Date
    04-19-2017
    Location
    Manchester, England
    MS-Off Ver
    Excel 2013, Office 365, Windows 10
    Posts
    14

    Re: Underlying row height

    I've been a little obsessed with whether this is possible or not since your original thread.

    Like MrShorty, I've been looking at how to get at the XML data, and whether you can easily get at it from within the file you're actually using. You can obviously get it manually by renaming and unzipping, and that part is possible to code for. (I've not written the code, but I've written code before that does similar jobs and it's pretty vanilla.)

    The biggest drawback is that even a simple, small Excel sheet can end up giving you an XML file that takes a relatively long time to create, open and interrogate. As you've said already, your filter changes frequently, is complex, and is applied manually, which means your XML file would have to be repeatedly Killed and would grow and grow, too.

    I'm going to stick my head above the parapet and say that while it might be just about possible to get the information you want (in that the data exists, is held within the XML structure and is available after some manipulation), I don't believe it's going to be feasible to use the XML data in your live file in any kind of straightforward way. There are a few posts I've found about parsing XML from within Excel, but I can't see how you'd easily adapt it to your scenario. My instinct is that you would have to spend a huge amount of time on this and you'd end up with a file that ran much more slowly that you'd find acceptable. As an example, even creating the .zip file from a single worksheet in the first place is not exactly lightning quick.

    (In case it proves useful: http://analystcave.com/vba-xml-working-xml-files/ )

  10. #10
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Underlying row height

    @thiefofthings - thank you - and I totally agree with you
    This particular thread is part of a couple of other issues that I am wrestling
    - I am trying to avoid any complicated code (or, indeed, complications of any sort)
    - I was just hoping that someone had found a simple way to get at that "secret" value
    - I live in the land of eternal hope...



    NOTE:
    I am still looking for a definitive answer to the question posed at the beginning of this thread
    Let's banish parsing XML from our minds - it seems too damn complicated..
    Last edited by kev_; 04-23-2017 at 12:06 PM.

  11. #11
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Underlying row height

    It seems to me that creating and parsing an XML file is a more complicated work-around than simply un-hiding a row, reading its RowHeight and hiding it again.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  12. #12
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Underlying row height

    @mikerickson - we are of one mind!

  13. #13
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Underlying row height

    I'm curious why this needs to be discovered while the row is hidden. (Aside from abstract curiosity). The RowHeight of a cell is inherently a visual thing and one could wait until the cell is visible before adjusting it.

  14. #14
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Underlying row height

    The purpose is to do quite the opposite to what Excel thinks we should do - it's being used to set the row height elsewhere.

    Imagine the reverse of:
    - advanced filter in sheet1, paste filtered results to sheet2

    My mission is to filter in sheet1, paste ALL rows to sheet2 without lifting the filter first - that is why I need the "secret" row height
    (the overall puzzle is solved - but I was trying to simplify things)

    And yes, in principle, it would be much easier to lift the filter, grab all row heights, replace the filter
    - but that assumes that the filters are not manually placed complex, cumulative, with variable sort

    And before you ask .... no, I am not being obtuse .... it is not my workbook - but it's been a fascinating challenge to turn Excel on its head!

  15. #15
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Underlying row height

    It sounds like you are trying to create a "PasteSpecial/Row Height" command, since copy/paste doesn't adjust row heights even of visible cells.

  16. #16
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Underlying row height

    I hadn't thought it through that far, but you are quite right. Perhaps I should patent it and sell it to Microsoft

  17. #17
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,343

    Re: Underlying row height

    But lifting the filter and putting it back in is trivially easy isn't it?
    save a custom view and then remove the filter (and do whatever you want) and put the custom view back in.

    Does that not work for all of your sheet?
    Last edited by scottiex; 04-23-2017 at 06:55 PM. Reason: for clarity

  18. #18
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Underlying row height

    Thanks scottiex - I will test that.....

    EDIT
    I did. It worked
    What an elementary case of tunnel-vision on my part!
    Last edited by kev_; 04-24-2017 at 03:58 AM.

  19. #19
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Underlying row height

    So, to tidy everything up on this thread ....

    To find the value H and leave the sheet as we found it...
    Please Login or Register  to view this content.

    Thanks to everyone who unwittingly followed me up this particular blind alley
    Last edited by kev_; 04-24-2017 at 09:01 AM.

  20. #20
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Underlying row height

    @mikerickson - some bonus code for you just in case you should ever need it
    Please Login or Register  to view this content.

  21. #21
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,343

    Re: Underlying row height

    Very pleased I was able to be helpful to a more senior member

  22. #22
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Underlying row height

    @scottiex That's the joy of the forum - we all learn from each other

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 0
    Last Post: 02-13-2016, 03:31 AM
  2. Replies: 1
    Last Post: 09-25-2015, 11:49 AM
  3. Replies: 4
    Last Post: 03-21-2015, 08:18 PM
  4. Replies: 2
    Last Post: 01-12-2015, 02:52 PM
  5. Macro to autofit row height, and then reduce back to original height
    By LesleyRicco in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-03-2013, 09:12 PM
  6. Replies: 17
    Last Post: 02-25-2009, 10:09 AM
  7. Replies: 3
    Last Post: 04-23-2007, 01:55 AM

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