VBA Code for Vlookup with formatting

  • Hey guys,

    I have very limited knowledge on VBA and would like some help please.

    I would like to do exactly what the vlookup function does but keeping the formatting of the parent cell where the content is being copied from, the parent cell contains spaces, tabs, bolds, underlines, bullet point and new lines.


    I have tried searching online for hours but haven't found anything and with my limited vba knowledge it's proving in being quite a difficult task.


    I have attached 2 pictures to explain what I would like to do.

    • Image 1: The description column is where I would like to use the vlookup equivalent to get the description from the worksheet in image 2.
    • Image 2: The whole array is also named "Product_Descriptions_txt" and this is the worksheet where I would like to copy the description from.

    I would Ideally like to use this formula "=VLOOKUP([@SKU];Product_Descriptions_txt;3;FALSE)" in the description column of image 1 then automatically apply the same formula to the rest of the rows in the description column.


    So I would like to

    1. Search for the "SKU" in image 1
    2. Get the description from the 3rd column (Column C) in image 2 (Product_Descriptions_txt)
    3. Paste the copied content into the "Description" column of image 1


    Any help will be highly appreciated as I have been struggling with this issue for quite a while now.


    Kind regards

    Image 1

    [Blocked Image: https://i.ibb.co/L18KVCh/1.jpg]


    Image 2

    [Blocked Image: https://i.ibb.co/xJ6Jfz9/2.jpg]

  • Hello and Welcome to the Forum :)


    Since Images are by definition inert objects ...


    Would much more effective ... to attach your file ...;)

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Like" icon ...just below...in the bottom right corner...:)

  • Hello and Welcome to the Forum :)


    Since Images are by definition inert objects ...


    Would much more effective ... to attach your file ...;)

    Hi! Thank you for the warm welcoming! :)
    I didn't upload the whole file as there is quite a bit of information that I would not like to be online

  • Why do you need VBA for this?


    Your data looks like it's in a Table so formulas will auto-populate as rows are added.

    I don't get what you're saying, I have tried using the vlookup formula as in my original post, it does the job fine but it does not paste the formatting.

    I wouldn't have a problem if I didn't need the formatting.

  • Hi! Thank you for the warm welcoming! :)
    I didn't upload the whole file as there is quite a bit of information that I would not like to be online


    Hi,


    Can easily understand your point of view ...


    A small sample file with fake data could help a lot ... as long as the workbook structure remains identical to the original ...

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Like" icon ...just below...in the bottom right corner...:)

  • Hi,


    Can easily understand your point of view ...


    A small sample file with fake data could help a lot ... as long as the workbook structure remains identical to the original ...

    Sooo when I was uploading the spreadsheet to my google drive with some false data, I randomly opened it with Google Sheets.

    I noticed that the formatting (besides bullet points) were all retained, which was unlike how Excel showed it to be.

    I then went ahead and converted my Excel file to a csv file and uploaded it to my website and the formatting is just as I would like to use it.


    Thank you for trying to help me, I would not have found out that the formatting was always there if you did not ask me to upload some false data.


    Kind regards

    Beebs :)

  • Glad you could fix your problem :)


    Thanks for your Thanks AND for the Like ;)

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Like" icon ...just below...in the bottom right corner...:)