Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
selecting current row plus the 2 above RocketRod Excel Programming 4 October 6th 08 04:53 AM
Selecting dates from current week with Macro Gemz Excel Programming 5 February 15th 08 04:46 PM
Selecting Current date Jim May Excel Discussion (Misc queries) 4 August 22nd 06 09:23 PM
SELECTING CURRENT DATE AT OPENING R VAN DEURSEN Excel Worksheet Functions 5 March 7th 05 07:38 AM
selecting current row information and transfering it. Alan M Excel Programming 3 December 15th 04 03:16 AM


All times are GMT +1. The time now is 12:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"