Keeping the hyperlink when copy and pasting using VBA

NamTran

New Member
Joined
Nov 4, 2021
Messages
1
Office Version
  1. 2019
Platform
  1. Windows
Hi all,

I'm using VBA to create an advanced filter. The process includes entering information in sheet "rPDU", then searching for information in sheet "Data" and finally returning the information after filtering in sheet "rPDU", you can see the attached code. However, the "Link" in "Product manual" column is lost when I do this.
Can anyone help me how to keep "Link" in this case?.
Thank you so much!

The code is here:

Sub Adv_Filter()

'Function declaration

Dim rg As Range
Dim criterial_rg As Range
Dim paste_rg As Range


'Deleting old results after refreshing the filter

Sheets("rPDU").Range("B20:AZ100").Delete

'Seting the function and range

Set rg = Sheets("Data").Range("B4").CurrentRegion
Set criterial_rg = Sheets("rPDU").Range("B14:Z15").CurrentRegion
Set paste_rg = Sheets("rPDU").Range("B20")

rg.AdvancedFilter xlFilterCopy, criterial_rg, paste_rg

End Sub

1636082184165.png
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Try using FilterInPlace and then copy
VBA Code:
Sub Adv_Filter()

    'Function declaration
    
    Dim rg As Range
    Dim criterial_rg As Range
    Dim paste_rg As Range
    
    
    'Deleting old results after refreshing the filter
    
    Sheets("rPDU").Range("B20:AZ100").Delete
    
    'Seting the function and range
    
    Set rg = Sheets("Data").Range("B4").CurrentRegion
    Set criterial_rg = Sheets("rPDU").Range("B14:Z15").CurrentRegion
    Set paste_rg = Sheets("rPDU").Range("B20")
    
    rg.AdvancedFilter xlFilterInPlace, criterial_rg
    
    rg.Cells.SpecialCells(xlCellTypeVisible).Copy Destination:=paste_rg

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,839
Messages
6,127,196
Members
449,368
Latest member
JayHo

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