+ Reply to Thread
Results 1 to 15 of 15

row height IF functions

  1. #1
    Registered User
    Join Date
    12-05-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    7

    row height IF functions

    I have a spreadsheet where I am trying to use an "IF" function to change the height of the row.

    Here's an example:

    Cell A1 equals 0. I want the equation to make the row heignt = 0.25 if the number isn't >0

    This is as far as I got and can't find the correct term for the row height.
    =IF(A833>0,"rowheight=15",rowheight=0.25)

    thanks

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: row height IF functions

    You can not alter row height via formulae, you would need to use VBA.

  3. #3
    Registered User
    Join Date
    12-05-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: row height IF functions

    VBA? What's that?

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: row height IF functions

    Visual Basic for Applications: http://en.wikipedia.org/wiki/Visual_...r_Applications

    In truth makes the above out to be more intimidating than it is... what you want to do is not too complex to automate but first we'd want to know how the values in A are altered - manual entry of result of another calculation ?
    Last edited by DonkeyOte; 12-05-2009 at 12:38 PM.

  5. #5
    Registered User
    Join Date
    12-05-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: row height IF functions

    the value that the IF is based on is = to a value on another page. The value on the other page is manually entered.

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: row height IF functions

    Thanks.

    Are the links consistent - eg A1=Sheet2!A1 etc ?

    Perhaps if you upload a simplified version of the file you're using that illustrates the links / formulae etc we can give you the code snippet you need.

    IMO I think it's best to work from the manual change rather than the Calculation - less overheads long term.

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

    Re: row height IF functions

    This UDF might help
    put this in a normal module
    Please Login or Register  to view this content.
    and this in the ThisWorkbook code module
    Please Login or Register  to view this content.
    Putting =RowHeight(A1,IF(A1=0,15,75)) in a cell (other than A1) will cause row 1 to be 15 when A1=0 and 75 otherwise.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  8. #8
    Registered User
    Join Date
    12-05-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: row height IF functions

    Here's a simplified version. The rown whose height I want to change are on sheet 2.

    --I forgot something important. I'm using excel 2003.
    Attached Files Attached Files
    Last edited by donanton; 12-05-2009 at 01:53 PM.

  9. #9
    Registered User
    Join Date
    04-04-2012
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003
    Posts
    1

    Red face Re: row height IF functions

    Use the IF function this way and you want to heighten rows with the word "SHIP' anywhere in column B
    Use a column on the worksheet outside of your working area, Lets say you are using Columns A:M, use Colmmn Z
    in Cell Z1 - Use the IF function to create a string (eg "abcdef")
    Function is =if(B1="SHIP","abcdef","")
    Drag this down Column Z as far as you want

    Format all Column Z to "Vertical Alignment" and do not "Shrink to Fit" in cell formating.

    When you get a hit on "SHIP" in Column B - all that Row will increase in height to accommodate the "abcdef" in column Z
    Shorten or lengthen "abcdef" to change height
    Multiple IF statements with diffent lenght strings will give different heights for different words
    Changing font size in Z is also a control over row height.
    Cheers from Oz
    Ross

  10. #10
    Registered User
    Join Date
    12-05-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: row height IF functions

    thanks, but ive switched to open office in the mean time and it's one of the little differences between the two. short story is it doesnt work in open office. thanks anyway

  11. #11
    Registered User
    Join Date
    11-21-2013
    Location
    CA
    MS-Off Ver
    Excel 360 Pro+
    Posts
    3

    Re: row height IF functions

    [QUOTE=mikerickson;2211002]This UDF might help....

    Hi Mike, I know this is a very old post. Google got me here though
    Thank you for this helpful post. I tried it in a new workbook (office 360 Pro+ on Win10).
    unfortunately its not working. Your code makes sense, I entered the VBA code in the right place.
    The new workbook only has the VBA code and a blank sheet1, and got
    A1 =1
    B1 =RowHeight(A1,IF(A1=0,15,75))

    B1 becomes 75, but height of row1 wont change.
    is there a setting I need to change in Excel that prevents this row height from changing?

    Edit..after the post..
    The problem was with excel (as always) not the code. thanks a lot.
    Last edited by Saad Hassuneh; 09-23-2019 at 11:22 PM. Reason: Problem solved

  12. #12
    Registered User
    Join Date
    11-21-2013
    Location
    CA
    MS-Off Ver
    Excel 360 Pro+
    Posts
    3

    Re: row height IF functions

    I'm sorry.. false alarm.. code works fine now. the code didn't run because there was fantom VBA projects still open.
    Thank you very much again for the nice code.

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

    Re: row height IF functions

    You're welcome

  14. #14
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2504
    Posts
    13,635

    Re: row height IF functions

    @saad
    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread

  15. #15
    Registered User
    Join Date
    05-25-2014
    Posts
    1

    Re: row height IF functions

    [QUOTE=mikerickson;2211002]This UDF might help

    I had a small problem when trying to add this to an existing module, in that the first two lines tried to attach themselves to the existing SUB that was in that module.

    Once I pasted the statement into a NEW module this worked well, Thank you.

    Also for the end users, I have used this formula in 24 rows in a model that I have been developing. In the worksheet I used a column to calculate the row number =Rows($R$1:$Rxx) where XX is the row that you are entering the formula into. (NOTE: I used Row R for my worksheet as it is outside of my print area, but you can use any column of course).

    In Column S I set an if statement to test the columns that had the responses, i.e. in this case to sum those columns, so that if the columns had a response then the height to be set to 12.5 points, if blank 0 points. Rather than having the if as part of the function. You can use the IF statement either way.

    In column T the RowHeight (this) function.

    What I have found is that it does slow up the calculation aspect of the workbook a little, but is understandable. You could as an option change the calculation to a manual one rather than Automatic if it becomes a problem.

+ 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