Set Rows Height also Exception in Range [Solved/Closed]

Report
Posts
77
Registration date
Saturday September 5, 2015
Status
Member
Last seen
March 8, 2017
-
Posts
77
Registration date
Saturday September 5, 2015
Status
Member
Last seen
March 8, 2017
-
Hello,

I would like to request that rows from 10 to 40 their height will be Set to 12.75
but exception rows 11, 16, 21, 26, 31, 36 height will be 25.5

'Rows("10:40").RowHeight = 12.75
but except
Rows("11").RowHeight = 25.5
Rows("16").RowHeight = 25.5
Rows("21").RowHeight = 25.5
Rows("26").RowHeight = 25.5
Rows("31").RowHeight = 25.5
Rows("36").RowHeight = 25.5

Thanks

2 replies


I am not certain what your question is! If that is what you want, then make it so! Are you trying to make a code that will make the changes?

Is the posted code your product, but it doesn't work? Let us know where you are stuck, please. You have done a great ob of stating the issue, but not quite describing what you want out of us! Where are you stuck?
2
Thank you

A few words of thanks would be greatly appreciated. Add comment

CCM 4043 users have said thank you to us this month

Posts
77
Registration date
Saturday September 5, 2015
Status
Member
Last seen
March 8, 2017
1
Hi
Thanks for response their is no error in the code I think that their any kind of loop and any exception condition could be apply because after every 15 rows same condition is applied 4 times for the rows.
Loop and exception condition can shorten and more conceptually program this code that I think,

Thanks
>
Posts
77
Registration date
Saturday September 5, 2015
Status
Member
Last seen
March 8, 2017

you mean something like this?

Sub setheightloop()
Dim setrows()
Dim n As Integer
setrows = Array(11, 16, 21, 26, 31, 36)

Rows("10:40").RowHeight = 12.75
For n = LBound(setrows) To UBound(setrows)
Rows(setrows(n)).RowHeight = 25.5
Next n

End Sub


or like this:
Sub setheightloop2()

For n = 10 To 40
If n Mod 5 = 1 Then
Rows(n).RowHeight = 25.5
Else
Rows(n).RowHeight = 12.75
End If
Next n

End Sub
Posts
77
Registration date
Saturday September 5, 2015
Status
Member
Last seen
March 8, 2017
1
Excellent Job
Both are perfect but second is much more like it
Thanks
Hi smuneeb,
What is the problem with the code you posted?