Results 1 to 6 of 6

Thread: retrieving excel row height

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2007
    Posts
    30

    retrieving excel row height

    VB6
    have an excel sheet open, all works well.

    I want to retrieve the height of a row and i cant seem to find any function to do it

    more precisely i want to do something like
    VB Code:
    1. For i = 1 To range.rows.count
    2.     Msgbox worksheet.row(i).height
    3. Next i

    only problem is worksheet.row doesnt have an index or any properties... nor does anything else i have been able to find.

    Thanks

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: retrieving excel row height

    Its based upon a Range object.
    VB Code:
    1. With Worksheets("Sheet1").Rows(1)
    2.     MsgBox .RowHeight
    3. End With
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    Addicted Member malik641's Avatar
    Join Date
    Sep 2005
    Location
    South Florida :-)
    Posts
    221

    Re: retrieving excel row height

    RobDog888 is right, it's based on the Range object.

    The object browser is your best friend when it comes to stuff like this. If you have the referenced checked for excel in your VB project, then you can press F2 to view the object browser. You'll see a combo box that says "<All Libraries>". Select "Excel" from the combo box to see all the classes of Excel. In the classes listbox select "Range" and in the "Members of 'class' " listbox you'll see all the Range's properties, methods, collections, etc. You'll find RowHeight in there. Much easier to navigate in there rather than Intellisense.





    If you find any of my posts of good help, please rate it

  4. #4
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: retrieving excel row height

    more precisely i want to do something like

    visual basic code:--------------------------------------------------------------------------------
    For i = 1 To range.rows.count
    Msgbox worksheet.row(i).height
    Next i
    Hi

    To find rowheight of all the rows in the range use Rob's code in your loop i.e

    VB Code:
    1. For i = 1 To range.rows.count
    2.    With Worksheets("Sheet1").Rows(i)
    3.          MsgBox .RowHeight
    4.    End With
    5. Next i

    Hope this helps...
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jan 2007
    Posts
    30

    Re: retrieving excel row height

    well actually this issue is resolved now but not by using the .rowheight property

    in excel you can resize rows, so some rows might be different heights than others. as far as i can see .RowHeight returns the average or the default row height.

    to get it to work i used some command like row(i).height... but im not on the same computer i coded it in... i'll post my code later

  6. #6
    Frenzied Member zaza's Avatar
    Join Date
    Apr 2001
    Location
    Borneo Rainforest Habits: Scratching
    Posts
    1,486

    Re: retrieving excel row height

    No it doesn't. Rowheight returns the height of the row corresponding to the range you passed. If you pass it a single row, then it will return the height of that row.

    But at least it is working now.


    zaza
    I use VB 6, VB.Net 2003 and Office 2010



    Code:
    Excel Graphing | Excel Timer | Excel Tips and Tricks | Add controls in Office | Data tables in Excel | Gaussian random number distribution (VB6/VBA,VB.Net) | Coordinates, Vectors and 3D volumes

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width