DoubleClick using Virtual Basic within Excel

fistral13

New Member
Joined
Dec 15, 2005
Messages
16
DoubleClick

Imagine a Microsoft Excel workbook in which one particular page has a column in which successive rows are occupied by various URL’s as text.

I wanted to convert each cell to be a HyperLink.

I could have done this manually for each active cell using:

Click right mouse button
Select “Copy”
Click right mouse button
Select “HyperLink”
Alt+T
Ctrl+C
Alt+E
Ctrl+V
Enter
Enter

By chance I found that for an active cell:

Double click left mouse button
Enter

had the effect of producing the required HyperLink with the URL as the text which was displayed, and moving down one row.

I could have repeated the double click and enter hundreds of times for each active cell, but that is very time consuming. So I tried to write a Macro to achieve the same effect as double click and enter.

When I used the path:

Tools > Macro > Record New Macro
repeated the keystrokes, and stopped recording, I found that the coding in the Macro was:

Range("H1930").Select
ActiveCell.FormulaR1C1 = "http://links.........?ID=602"
Range("H1931").Select

As this was not suitable for any active cell selected I tried the following coding:

ActiveCell.Select
Keystrokes:
Click right mouse button
Select “Copy”
Click right mouse button
Select “HyperLink”
Alt+T
Ctrl+C
Alt+E
Ctrl+V
Enter
Enter

The coding in my Macro then became:

(After I had added the lines in Dark Red colour.)

ActiveCell.Select
Selection.Copy
Application.CutCopyMode = False
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:= _
"http://links.....?ID=603", TextToDisplay:= _http://links.....ID=603

ActiveCell.Offset(1, 0).Select


The Macro did not work as required, as it repeated the previous URL.

My question is what should replace the coding coloured Violet in the above Macro?
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Replace it with

ActiveSheet.Hyperlinks.Add Anchor:=ActiveCell, Address:= _
ActiveCell.Text, TextToDisplay:= ActiveCell.Text
 
Upvote 0
Hi Ceduljko,

Thanks for your prompt reply

After sending my question I restructured the Macro:

For I = 1 To 1000

Selection.Copy
Application.CutCopyMode = False
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:=ActiveCell.Value
ActiveCell.Activate
ActiveCell.Offset(1, 0).Select

Next I

That coding proved to be successful.

We are pretty much on the same wavelength - Thanks again
 
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,540
Members
449,038
Latest member
Guest1337

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top