VBA Code to combine VLOOKUP and Pastespecial

EzoArk

New Member
Joined
May 24, 2019
Messages
1
Every morning I have to manually copy and paste information from cells because VLOOKUP doesn't carry over formatting. I am very beginner to VBA.... Basically I have cells that contain information laid out like such:

[TABLE="width: 500"]
<tbody>[TR]
[TD]Product Name[/TD]
[TD]DOCKET[/TD]
[/TR]
[TR]
[TD]ABC[/TD]
[TD]<del>1234</del>TEST[/TD]
[/TR]
[TR]
[TD]BCD[/TD]
[TD]2345 TEST[/TD]
[/TR]
</tbody>[/TABLE]

Any help is appreciated putting together VBA Code or functions to copy the formatting and values due to the strikethroughs through some text. I just need a way to get VLOOKUP to carry over the formatting of the strikethroughs and even print them on a new sheet.
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
hello. PLEASE back-up your file before running the code, and edit as required. regards

Code:
Sub HowIsThis()


    Dim i As Long
    Dim rngLoop As Excel.Range
    Dim rngProductCodes As Excel.Range
    Dim rngLookupTable As Excel.Range
    
    If MsgBox(Prompt:="Is file backed up", Buttons:=vbQuestion + vbYesNo + vbDefaultButton2, Title:="Please backup file before running code") = vbYes Then
        MsgBox Prompt:="Lookup results will be place in the cell next to the product names", Title:="Please note"
        Set rngProductCodes = Application.InputBox(Prompt:="Please Select Product Names", Title:="EzoArk Special Lookup", Type:=8)
        Set rngLookupTable = Application.InputBox(Prompt:="Please Select Lookup Table", Title:="EzoArk Special Lookup", Type:=8)
        Application.ScreenUpdating = False
        On Error Resume Next
        For Each rngLoop In rngProductCodes
            i = Application.WorksheetFunction.Match(rngLoop.Value2, rngLookupTable.Columns(1))
            rngLookupTable.Cells(i, 2).Copy rngLoop.Offset(, 1)
        Next rngLoop
    End If


End Sub
 
Upvote 0

Forum statistics

Threads
1,224,749
Messages
6,180,725
Members
452,995
Latest member
isldboy

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