Set Rows Height also Exception in Range

Solved/Closed
smuneeb Posts 67 Registration date Saturday September 5, 2015 Status Member Last seen March 8, 2017 - Nov 20, 2015 at 03:27 PM
smuneeb Posts 67 Registration date Saturday September 5, 2015 Status Member Last seen March 8, 2017 - Nov 21, 2015 at 03:34 PM
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 responses

Blocked Profile
Nov 20, 2015 at 05:33 PM
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
smuneeb Posts 67 Registration date Saturday September 5, 2015 Status Member Last seen March 8, 2017 1
Nov 21, 2015 at 02:15 AM
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
0
RayH > smuneeb Posts 67 Registration date Saturday September 5, 2015 Status Member Last seen March 8, 2017
Nov 21, 2015 at 02:17 PM
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
0
smuneeb Posts 67 Registration date Saturday September 5, 2015 Status Member Last seen March 8, 2017 1
Nov 21, 2015 at 03:34 PM
Excellent Job
Both are perfect but second is much more like it
Thanks
0
Hi smuneeb,
What is the problem with the code you posted?
0