VBA Code For Copying Cell Formatting

socalhawki

New Member
Joined
Aug 17, 2011
Messages
1
I have an Excel workbook that I need help with to copy cell formatting.

The current workbook has worked as needed using VLOOKUP to return the corresponding value for a specified value. However, I now need to copy cell formatting in addition to the value and VLOOKUP does not allow that.

Here are the basics of the problem.

1.) There are 216 potential numeric values for a 3 digit number, each digit limited to a value of 0-5. So we can have values 000, 001, 002, 003, 004, 005, 010, 011...545, 550, 551, 552, 553, 554, 555. These are listed in column A.

2.) A random number generator is used to randomize these numbers which are associated with a data string for each number. I am using the RAND() function to randomize the data; by hitting F9, all of the data is randomized. The RAND() is in column B and the resultant random number is in column C (changes as F9 is hit).

3.) I have 216 text values that remain constant in column D. What changes is the 3 digit number associated with the text value. For example, "Jim" could have value 014 and then after F9 is hit, it could have value 431. This is true for all 216 rows.

4.) On another worksheet, I use VLOOKUP to find the text associated with the random number value I want. So for example to find the text associated with '011' the formula I use is VLOOKUP("011", DataR!C1:D216,2,FALSE).

The problem I have is I now need to copy the cell formatting in addition to the value. So for example, a red background would be associated with 1 group and a green background would be associated with a second group. So in addition to copying the text associated with '011' I also need to copy the cell formatting.

Can anyone provide any guidance on this? Thanks in advance.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Forum statistics

Threads
1,224,521
Messages
6,179,286
Members
452,902
Latest member
Knuddeluff

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