Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming,microsoft.public.vb.controls
|
|||
|
|||
![]()
Is there a forum or something dedicated to vbAccelerator controls?
I have a grid placed on an XL VBA userform, and was wondering how would I set the width of the two columns, equally, upon startup. This is my code so far: Private Sub UserForm_Initialize() With grdTransCalc .Header = True .AddColumn vKey:="TOTAL", sHeader:="Total", ealign:=ecgHdrTextALignCentre .AddColumn vKey:="AMT", sHeader:="Amount", ealign:=ecgHdrTextALignCentre .AutoWidthColumn "TOTAL" .AutoWidthColumn "AMT" If .ColumnWidth("TOTAL") < 60 Then .ColumnWidth("TOTAL") = .Width / 2 If .ColumnWidth("AMT") < 60 Then .ColumnWidth("AMT") = .Width / 2 End With End Sub The above code doesn't space the columns correctly! Is there a better way? -- Julian Milano |
#2
![]()
Posted to microsoft.public.excel.programming,microsoft.public.vb.controls
|
|||
|
|||
![]()
It appears that the AutoWidthColumn sizes them to the length of the text.
Try this: With vbalGrid1 .Header = True .AddColumn "TOTAL", "TOTAL", ecgHdrTextALignCentre, , 60 .AddColumn "AMT", "AMT", ecgHdrTextALignCentre, , 60 ' .AutoWidthColumn "TOTAL" ' .AutoWidthColumn "AMT" End With "Julian Milano" wrote in message ... Is there a forum or something dedicated to vbAccelerator controls? I have a grid placed on an XL VBA userform, and was wondering how would I set the width of the two columns, equally, upon startup. This is my code so far: Private Sub UserForm_Initialize() With grdTransCalc .Header = True .AddColumn vKey:="TOTAL", sHeader:="Total", ealign:=ecgHdrTextALignCentre .AddColumn vKey:="AMT", sHeader:="Amount", ealign:=ecgHdrTextALignCentre .AutoWidthColumn "TOTAL" .AutoWidthColumn "AMT" If .ColumnWidth("TOTAL") < 60 Then .ColumnWidth("TOTAL") = .Width / 2 If .ColumnWidth("AMT") < 60 Then .ColumnWidth("AMT") = .Width / 2 End With End Sub The above code doesn't space the columns correctly! Is there a better way? -- Julian Milano |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Outline/group 2 columns- what puts the control on the left vs righ | Excel Discussion (Misc queries) | |||
Compare two columns by aligning same-values and spacing out differences | Excel Worksheet Functions | |||
calendar control in 3 columns | Excel Discussion (Misc queries) | |||
Pasting from clipboard-how to control text-to-columns delimiting | Excel Discussion (Misc queries) | |||
Problem hiding/unhiding columns using combo control | Excel Programming |