I realise there is already a ‘sticky’ topic – Useful Excel and VBA References – under Excel in the Office Applications section but whilst it is indeed most helpful, it references Web sites to look up from which the Member may choose one which doesn’t relate to the query they have in mind.
It would, of course, require strict policing and might mean some posts get rejected but I believe it could be useful. I have listed below two examples of what might be considered.
This code shows how to change the column width in multiple sheets simultaneously.
Code: Select all
Sub Change_Column_Width()
Dim worksheetnames() As Variant
worksheetnames = Array("Sheet1", "Sheet2", "Sheet3", "Sheet4", "Sheet5") 'and other worksheets
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' worksheetnames = Array("Operations", "Staff", "Support") 'and other worksheets '
' CHANGE worksheet NAMES TO SUIT '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Application.ScreenUpdating = False
For i = 0 To UBound(worksheetnames)
MsgBox worksheetnames(i)
With Worksheets(worksheetnames(i))
.Columns("A:A").ColumnWidth = 11.5
.Columns("B:B").ColumnWidth = 8.75
.Columns("C:G").ColumnWidth = 11.5 ' <<<<<<<<< Adjacent columns
.Columns("H:H").ColumnWidth = 2.75
.Columns("I:I").ColumnWidth = 11.5
.Columns("J:J").ColumnWidth = 11.75
.Columns("R:R").ColumnWidth = 13.38
'''''''''''''''''''''
' and other columns '
'''''''''''''''''''''
End With
Next i
Application.ScreenUpdating = True
End Sub
Code: Select all
Sub Mergethecells()
Range("I19:K20").Select ' < Change to suit needs
Range("I19").MergeArea.Value = "SELECT AND COPY ABOVE AND PASTE TO THE HEADING" ' < Change to suit needs
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
End Sub