Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Set row height in excel vba

Posted on 2014-02-25
4
Medium Priority
?
4,241 Views
Last Modified: 2014-02-25
How can I set the row height to a specific value in excel vba? I want all the rows from row 2 down to the last row that has a value in column A set to 15. How can this be written in vba code?
0
Comment
Question by:Lawrence Salvucci
  • 3
4 Comments
 
LVL 53

Accepted Solution

by:
Rgonzo1971 earned 1000 total points
ID: 39885644
Hi,

pls try

Sub macro()

For Each c In Range(Range("A1"), Range("A" & Rows.Count).End(xlUp))
    If c <> "" Then
     c.RowHeight = 15
    End If
Next
End Sub

Open in new window

Regards
0
 
LVL 22

Expert Comment

by:spattewar
ID: 39885651
one way to do it is

Sub ChangeRowHeight()

    ActiveSheet.Range("A3").Select
    ActiveSheet.Range(Selection, Selection.End(xlDown)).RowHeight = 25
   
End Sub

hope this helps.
0
 
LVL 22

Expert Comment

by:spattewar
ID: 39885652
sorry change 25 to 15 in my post
0
 
LVL 22

Assisted Solution

by:spattewar
spattewar earned 1000 total points
ID: 39885656
my code will break if you have empty cells in column A. in that case use the code posted by  Rgonzo1971

just modifying the code a bit

Sub macro()

Range(Range("A1"), Range("A" & Rows.Count).End(xlUp)).RowHeight = 15

End Sub
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question