Solved

Set row height in excel vba

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

Accepted Solution

by:
Rgonzo1971 earned 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility
sorry change 25 to 15 in my post
0
 
LVL 22

Assisted Solution

by:spattewar
spattewar earned 250 total points
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now