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

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
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,223,711
Messages
6,174,025
Members
452,542
Latest member
Bricklin

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