Detect Column index pressed in Excel

Hello EE,

How can I know via code (macro)  which column index was Clicked (cell or header)  ?

What is the code behind for that ?

if I press Cell (3,3)  I would like to know that it was Column 3   or ("C")
LVL 1
PhilippeRenaudAsked:
Who is Participating?
 
Rory ArchibaldConnect With a Mentor Commented:
I suspect that Sender.Selection.Column would be the syntax though you may have to cast Sender as AxSpreadsheet first. e might also be the range itself.
0
 
kgerbChief EngineerCommented:
put the following in the worksheet code pane for the desired worksheet.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
MsgBox "A cell in column " & Target.Column & " was clicked"
End Sub

Open in new window

Kyle
0
 
PhilippeRenaudAuthor Commented:
Ok, do you know maybe was is the difference in VB ?
actually its a Excel control I have and I have the same possible event except that it goes as follow:


Private Sub AxSpreadsheet2_SelectionChange(sender As Object, e As System.EventArgs) Handles AxSpreadsheet2.SelectionChange

End Sub


I dont have Target as Range inside... the parameter is  e as EvenArgs...

maybe it's out of your scope ?
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
kgerbChief EngineerCommented:
Yeah, I'm not up on .Net.  Just VBA.  I'll go get help.

EDIT:
Ok, the cavalry will be here soon.

Kyle
0
 
PhilippeRenaudAuthor Commented:
You gonna request attention ?
0
 
kgerbChief EngineerCommented:
0
 
PhilippeRenaudAuthor Commented:
thanks, If I may... also, I was asking this quesiton because I was trying to get the column click when a user delete the entire column.

I have 2 Spreadsheet and when the user delete a column I wanted to programmatically delete the same column on the other spreadsheet...but looks like there is no event for the column deleted...

so I thought If I can know the column index before then I compare the excel sheets.. I could my self delete the column
0
 
PhilippeRenaudAuthor Commented:
Thanks, also I have a bigger problem related to Excel Control on this question :


http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_27635758.html


Any idea excel experts? Im getting crazy not finding a solution.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.