Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Information about activecell before clicking on hyperlink

Hi,
In my model I have inserted hyperlinks with subadresses in the same sheet
(or other sheets in the workbook).
When the user clicks on a hyperlink a coderoutine will start (the event
Worksheet_FollowHyperlink). In that routine I need to know the activecell
before the targetcell in the hyperlink is activated.
Thanks in advance for any help or comment.

Kind Regards
Mats
ESI Update
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,489
Default Information about activecell before clicking on hyperlink

Hi,

Try this,

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

MsgBox Target.Range.Parent.Name & "!" & Target.Range.Address

End Sub

cheers
Andy

Mats Nilsson wrote:
Hi,
In my model I have inserted hyperlinks with subadresses in the same sheet
(or other sheets in the workbook).
When the user clicks on a hyperlink a coderoutine will start (the event
Worksheet_FollowHyperlink). In that routine I need to know the activecell
before the targetcell in the hyperlink is activated.
Thanks in advance for any help or comment.

Kind Regards
Mats
ESI Update


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Information about activecell before clicking on hyperlink

Hi Andy,
Thanks for your answer but i didn´t get the activecell before the user
clicks on the hyperlink.
The parent = the worksheet name.
/Mats

--
ESI Update


"Andy Pope" wrote:

Hi,

Try this,

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

MsgBox Target.Range.Parent.Name & "!" & Target.Range.Address

End Sub

cheers
Andy

Mats Nilsson wrote:
Hi,
In my model I have inserted hyperlinks with subadresses in the same sheet
(or other sheets in the workbook).
When the user clicks on a hyperlink a coderoutine will start (the event
Worksheet_FollowHyperlink). In that routine I need to know the activecell
before the targetcell in the hyperlink is activated.
Thanks in advance for any help or comment.

Kind Regards
Mats
ESI Update


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,489
Default Information about activecell before clicking on hyperlink

What did that code give you then?

Mats Nilsson wrote:
Hi Andy,
Thanks for your answer but i didn´t get the activecell before the user
clicks on the hyperlink.
The parent = the worksheet name.
/Mats


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Information about activecell before clicking on hyperlink

Hi,
I got the sheetname and the Range where you click on the hyperlink (the
anchor).
In this Case "Resultatbudget!$L$1".


I would like to get the cell which was selected before you click on the
hyperlink.
e.g "Resultatbudget!$N$30".
/Mats

--
ESI Update


"Andy Pope" wrote:

What did that code give you then?

Mats Nilsson wrote:
Hi Andy,
Thanks for your answer but i didn´t get the activecell before the user
clicks on the hyperlink.
The parent = the worksheet name.
/Mats


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,489
Default Information about activecell before clicking on hyperlink

Then you will need to store the previous active cell in a variable as
the cell could be any one the cells on the sheet.

Add a private variable to the sheet module,

Private m_rngACell as range


The add code to the SelectionChange event,

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
set m_rnacell = target
End Sub

The in the FollowHyperlink event
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
MsgBox m_rngACell.Parent.Name & "!" & m_rngACell.Address
End Sub

Cheers
Andy

Mats Nilsson wrote:
Hi,
I got the sheetname and the Range where you click on the hyperlink (the
anchor).
In this Case "Resultatbudget!$L$1".


I would like to get the cell which was selected before you click on the
hyperlink.
e.g "Resultatbudget!$N$30".
/Mats


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Information about activecell before clicking on hyperlink

Hi,

I think there will be problems to store information in a variable when VBA
isn´t active until next selection change. Maybe a static variable could work.

It´s possible to store the information in cells in the worksheet. i think I
will use a code like this.
"Private Sub Worksheet_SelectionChange(ByVal Target As Range)
ActiveSheet.Cells(1, 1).Value = ActiveSheet.Cells(2, 1).Value
ActiveSheet.Cells(2, 1).Value = Target.Address
rngAcellpr = ActiveSheet.Cells(1, 1).Value
rngAcell = ActiveSheet.Cells(2, 1).Value"

Thanks for your help.
Mats
--
ESI Update


"Andy Pope" wrote:

Then you will need to store the previous active cell in a variable as
the cell could be any one the cells on the sheet.

Add a private variable to the sheet module,

Private m_rngACell as range


The add code to the SelectionChange event,

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
set m_rnacell = target
End Sub

The in the FollowHyperlink event
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
MsgBox m_rngACell.Parent.Name & "!" & m_rngACell.Address
End Sub

Cheers
Andy

Mats Nilsson wrote:
Hi,
I got the sheetname and the Range where you click on the hyperlink (the
anchor).
In this Case "Resultatbudget!$L$1".


I would like to get the cell which was selected before you click on the
hyperlink.
e.g "Resultatbudget!$N$30".
/Mats


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,489
Default Information about activecell before clicking on hyperlink

If your worried about the variable losing it contents then use a named
range to store the information in.

Mats Nilsson wrote:
Hi,

I think there will be problems to store information in a variable when VBA
isn´t active until next selection change. Maybe a static variable could work.

It´s possible to store the information in cells in the worksheet. i think I
will use a code like this.
"Private Sub Worksheet_SelectionChange(ByVal Target As Range)
ActiveSheet.Cells(1, 1).Value = ActiveSheet.Cells(2, 1).Value
ActiveSheet.Cells(2, 1).Value = Target.Address
rngAcellpr = ActiveSheet.Cells(1, 1).Value
rngAcell = ActiveSheet.Cells(2, 1).Value"

Thanks for your help.
Mats


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
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
Suppress hyperlink Dialogue box when clicking on Link Brent E Excel Discussion (Misc queries) 1 October 16th 08 08:58 PM
Clicking hyperlink causes toolbar to show TerryTutor Excel Discussion (Misc queries) 12 October 4th 07 03:33 PM
Eliminate second browse box when right clicking for hyperlink Dirter Scott Excel Worksheet Functions 0 November 1st 06 03:38 AM
Running code by clicking on a hyperlink cell matpj[_53_] Excel Programming 3 March 29th 06 02:27 PM
Right clicking on text does not bring up hyperlink option Morocco Mole Excel Discussion (Misc queries) 2 August 4th 05 12:28 AM


All times are GMT +1. The time now is 01:16 PM.

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

About Us

"It's about Microsoft Excel"