ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Advice about loop and cell action (https://www.excelbanter.com/excel-programming/302247-advice-about-loop-cell-action.html)

Tetsuhara

Advice about loop and cell action
 
Hi, I am a new learner. I created the loop below with the
help of macro. Now I am wondering is there anyway to
shorten this block of code - (also any statements that i
can safely leave out?)

Thank you. My question may sound foolish..I am grateful
for your understanding and assistance.
Tetsu Hara

Dim row As Integer
row = 11
Do While row < 157
row = row + 2
For col = 1 To 3
Range(Cells(row, col), Cells(row + 1, col)).Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
Next col
Loop

Bob Phillips[_6_]

Advice about loop and cell action
 
Dim row As Integer
For row = 11 To 156
For col = 1 To 3
With Range(Cells(row+2, col), Cells(row + 3, col))
.MergeCells = True
End With
Next col
Next row

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Tetsuhara" wrote in message
...
Hi, I am a new learner. I created the loop below with the
help of macro. Now I am wondering is there anyway to
shorten this block of code - (also any statements that i
can safely leave out?)

Thank you. My question may sound foolish..I am grateful
for your understanding and assistance.
Tetsu Hara

Dim row As Integer
row = 11
Do While row < 157
row = row + 2
For col = 1 To 3
Range(Cells(row, col), Cells(row + 1, col)).Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
Next col
Loop





All times are GMT +1. The time now is 07:15 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com