Selecting the Current Column ?

  • Thread starter Michael Hudston
  • Start date
M

Michael Hudston

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
 
G

Gary''s Student

The current column is the column containing the ActiveCell:

ActiveCell.EntireColumn.Select
 
J

Jim Rech

Or just insert a column without selecting it:

ActiveCell.EntireColumn.Insert

--
Jim
| 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
 
M

Michael Hudston

Cheers both of you. Why is it the simple answers always the hardest to find.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top