Cleaning up some link copying code

RoyR

Board Regular
Joined
Jan 25, 2012
Messages
62
Following is an example of code I use to copy cells from one workbook to the active workbook.

Code:
Range("A21").Value = Workbooks("MovieDB.xls").Worksheets("Data").Range("R" & RowNum).Value 'Genre1

This works very well but if the data in the cell is a hyperlink it will not keep the link so I use ugly code as follows

Code:
Windows("MovieDB.xls").Activate
    Range("AU" & RowNum).Copy 'External Link 1
        Windows(WB).Activate
            Range("L3").PasteSpecial

I would like to change that into

Code:
Range("L3").Value = Workbooks("MovieDB.xls").Worksheets("Data").Range("AU" & RowNum).Value 'External Link 1

but I can not figure out how to remove the .Value in the first range so that the link is also copied and not just the cells value

Any sugestions...
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
I got it down to two lines of code

Code:
Workbooks("MovieDB.xls").Worksheets("Data").Range("AU" & RowNum).Copy
Range("L3").PasteSpecial

This will stop the constant switching from one workbook to another and I think will speed up the macro. I use Application.ScreenUpdating = False so I don't actually see the macro switch from one book to the other.

Trying hard to learn to write better code so any tips are welcome. Thanks to those who took the time to look at this.
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,865
Members
449,052
Latest member
Fuddy_Duddy

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