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:

Product NameDOCKET
ABC<del>1234</del>TEST
BCD2345 TEST

<tbody>
</tbody>

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

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
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,214,581
Messages
6,120,372
Members
448,957
Latest member
BatCoder

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