Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
visual basic macro help
i need a visual basic macro that will select all columns containing
comments and then insert an empty column to the right of each selected column. any help? i found this code: Dim iColumn As Long On Error Resume Next iColumn = Application.Match("Duration", Rows(1), 0) On Error GoTo 0 If iColumn 0 Then Columns(iColumn).Select End If for selecting columns that have "duration" in row 1, and this code: Dim CommRange As Range Dim MyCell As Range Dim CurWks As Worksheet Set CurWks = ActiveSheet On Error Resume Next Set CommRange = CurWks.Cells _ .SpecialCells(xlCellTypeComments) On Error GoTo 0 for selecting cells with comments. i'm not sure how to select columns with comments, though, and i'm shooting in the dark for inserting colums to the right of the selections... maybe add "Selection.EntireColumn.Select" after the ..specialcells() bit to change the cell selections to column selections? either Selection.Entirecolumn.Insert or Selection.Insert Shift:=xlToRight to insert the columns? i would guess that the second option will insert to the right instead of to the left, but i'm just guessing. as you may have noticed, i've never used visual basic before, so i'm probably overlooking something obvious. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Can I run Visual Basic procedure using Excel Visual Basic editor? | Excel Programming | |||
Visual Basic Macro | Excel Discussion (Misc queries) | |||
Visual Basic Macro For Solver | Excel Programming | |||
Interpolation Visual Basic Macro!!!! | Excel Programming | |||
visual basic macro in excel | Excel Programming |