Solved

Set row height in excel vba

Posted on 2014-02-25
4
2,870 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 49

Accepted Solution

by:
Rgonzo1971 earned 250 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 250 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

776 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