Answered by:
Please Help Me????

Question
-
I do not understand to do this Exam??? please tell me step by step....
- In the Order Form worksheet, create a macro that formats the Column Width to e exactly 20 pixels and applies the middle align format to the cell contents. Name the macro Width and store it in only this workbook. (Note: accept all other default settings)
Friday, May 6, 2016 12:08 AM
Answers
-
Here's the correct code:-
Sub Width()
'
' Width Macro
''
Columns("A:A").ColumnWidth = 2.14
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End SubIn the exam the user would be required to achieve the above by making the selections in the GUI and then saving the macro.
- Marked as answer by Davin MickelsonEditor Sunday, May 8, 2016 7:11 PM
Sunday, May 8, 2016 3:34 PM
All replies
-
Hi, Js.
You probably want to do something similar to the code below.
Note that this was just grabbing column "A".
Sub Width() Columns("A:A").ColumnWidth = 20 Columns("A:A").HorizontalAlignment = xlCenter End Sub
Good luck!
Best wishes, Davin Mickelson
Friday, May 6, 2016 1:48 AMAnswerer -
Davin - I reckon that fails testing.
After running your code column width is set to:-
Width: 20.00 (145 pixels) [user wanted 20 pixels]
- and your second line of code fails to set the Middle Align at all (it doesn't change it).
Note to Js Thao:-
You need to post here:-
- to get answers to EXCEL questions.
- Edited by trip_to_tokyo Sunday, May 8, 2016 2:13 PM
Sunday, May 8, 2016 2:03 PM -
Here's the correct code:-
Sub Width()
'
' Width Macro
''
Columns("A:A").ColumnWidth = 2.14
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End SubIn the exam the user would be required to achieve the above by making the selections in the GUI and then saving the macro.
- Marked as answer by Davin MickelsonEditor Sunday, May 8, 2016 7:11 PM
Sunday, May 8, 2016 3:34 PM