Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selecting the Current Column ?
How do I select the current Column in VBA, so I can then insert a whole new
one to the left of it? Ive got most of the code down, but I cant select a single column for some reason. Help Please Private Sub Update_LRU_List_Click() Dim EBS_LRU_Count As Double Dim Trend_LRU_Count As Double Dim LRU_Diff As Double EBS_LRU_Count = Sheets("BASIC CHART DATA").Range("D6") Trend_LRU_Count = Sheets("BASIC CHART DATA").Range("D7") LRU_Diff = EBS_LRU_Count - Trend_LRU_Count Application.Goto Reference:=Worksheets("Trend Analysis").Range("I5").Offset(0, Trend_LRU_Count), Scroll:=False If LRU_Diff 0 Then For Xnum = 1 To LRU_Diff 'Locates Current Column, depent on Number of Missing LRU's Application.Goto Reference:=Worksheets("Trend Analysis").Range("I5").Offset(0, Xnum + 1), Scroll:=False 'Select Current Column 'INSERT LINE HERE TO SELECT THE WHOLE OF THE CURRENT COLUMN 'Insert a new Column immedaitely to the right of the Current Column Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove ' Populate heading of New Column from LRU List Next End If End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selecting the Current Column ?
The current column is the column containing the ActiveCell:
ActiveCell.EntireColumn.Select -- Gary''s Student - gsnu200806 "Michael Hudston" wrote: How do I select the current Column in VBA, so I can then insert a whole new one to the left of it? Ive got most of the code down, but I cant select a single column for some reason. Help Please Private Sub Update_LRU_List_Click() Dim EBS_LRU_Count As Double Dim Trend_LRU_Count As Double Dim LRU_Diff As Double EBS_LRU_Count = Sheets("BASIC CHART DATA").Range("D6") Trend_LRU_Count = Sheets("BASIC CHART DATA").Range("D7") LRU_Diff = EBS_LRU_Count - Trend_LRU_Count Application.Goto Reference:=Worksheets("Trend Analysis").Range("I5").Offset(0, Trend_LRU_Count), Scroll:=False If LRU_Diff 0 Then For Xnum = 1 To LRU_Diff 'Locates Current Column, depent on Number of Missing LRU's Application.Goto Reference:=Worksheets("Trend Analysis").Range("I5").Offset(0, Xnum + 1), Scroll:=False 'Select Current Column 'INSERT LINE HERE TO SELECT THE WHOLE OF THE CURRENT COLUMN 'Insert a new Column immedaitely to the right of the Current Column Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove ' Populate heading of New Column from LRU List Next End If End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selecting the Current Column ?
Or just insert a column without selecting it:
ActiveCell.EntireColumn.Insert -- Jim "Gary''s Student" wrote in message ... | The current column is the column containing the ActiveCell: | | ActiveCell.EntireColumn.Select | -- | Gary''s Student - gsnu200806 | | | "Michael Hudston" wrote: | | How do I select the current Column in VBA, so I can then insert a whole new | one to the left of it? | | Ive got most of the code down, but I cant select a single column for some | reason. | | Help Please | | Private Sub Update_LRU_List_Click() | | Dim EBS_LRU_Count As Double | Dim Trend_LRU_Count As Double | Dim LRU_Diff As Double | | EBS_LRU_Count = Sheets("BASIC CHART DATA").Range("D6") | Trend_LRU_Count = Sheets("BASIC CHART DATA").Range("D7") | LRU_Diff = EBS_LRU_Count - Trend_LRU_Count | | Application.Goto Reference:=Worksheets("Trend | Analysis").Range("I5").Offset(0, Trend_LRU_Count), Scroll:=False | | If LRU_Diff 0 Then | For Xnum = 1 To LRU_Diff | | 'Locates Current Column, depent on Number of Missing LRU's | Application.Goto Reference:=Worksheets("Trend | Analysis").Range("I5").Offset(0, Xnum + 1), Scroll:=False | | 'Select Current Column | 'INSERT LINE HERE TO SELECT THE WHOLE OF THE CURRENT COLUMN | | 'Insert a new Column immedaitely to the right of the Current | Column | Selection.Insert Shift:=xlToRight, | CopyOrigin:=xlFormatFromLeftOrAbove | | ' Populate heading of New Column from LRU List | | Next | End If | End Sub |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selecting the Current Column ?
Cheers both of you. Why is it the simple answers always the hardest to find.
"Jim Rech" wrote: Or just insert a column without selecting it: ActiveCell.EntireColumn.Insert -- Jim "Gary''s Student" wrote in message ... | The current column is the column containing the ActiveCell: | | ActiveCell.EntireColumn.Select | -- | Gary''s Student - gsnu200806 | | | "Michael Hudston" wrote: | | How do I select the current Column in VBA, so I can then insert a whole new | one to the left of it? | | Ive got most of the code down, but I cant select a single column for some | reason. | | Help Please | | Private Sub Update_LRU_List_Click() | | Dim EBS_LRU_Count As Double | Dim Trend_LRU_Count As Double | Dim LRU_Diff As Double | | EBS_LRU_Count = Sheets("BASIC CHART DATA").Range("D6") | Trend_LRU_Count = Sheets("BASIC CHART DATA").Range("D7") | LRU_Diff = EBS_LRU_Count - Trend_LRU_Count | | Application.Goto Reference:=Worksheets("Trend | Analysis").Range("I5").Offset(0, Trend_LRU_Count), Scroll:=False | | If LRU_Diff 0 Then | For Xnum = 1 To LRU_Diff | | 'Locates Current Column, depent on Number of Missing LRU's | Application.Goto Reference:=Worksheets("Trend | Analysis").Range("I5").Offset(0, Xnum + 1), Scroll:=False | | 'Select Current Column | 'INSERT LINE HERE TO SELECT THE WHOLE OF THE CURRENT COLUMN | | 'Insert a new Column immedaitely to the right of the Current | Column | Selection.Insert Shift:=xlToRight, | CopyOrigin:=xlFormatFromLeftOrAbove | | ' Populate heading of New Column from LRU List | | Next | End If | End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
selecting current row plus the 2 above | Excel Programming | |||
Selecting dates from current week with Macro | Excel Programming | |||
Selecting Current date | Excel Discussion (Misc queries) | |||
SELECTING CURRENT DATE AT OPENING | Excel Worksheet Functions | |||
selecting current row information and transfering it. | Excel Programming |