Colour Gradients - Lookup next non-empty cell

nicksoph

Board Regular
Joined
Jun 13, 2009
Messages
57
Hi
I’m using Excel to generate images in Coreldraw using vba and am trying to find a way of generating colour gradient data in excel. I have a spreadsheet with tens of thousands of rows and want to assign an RGB colour to each row. I am struggling with which Excel commands should be used.

To try and explain Im using an example of a Grey image where in each row Im trying to generate a single integer between 0 and 255 but I hope to be able to use what I learn to create 3 columns representing RGB.

Imagine a spreadsheet with 2 columns: In Column A, I want to enter values between 0 and 255 in the top and bottom rows and also enter values (also between 0-255) in any number of arbitrary rows between them – in this example imagine I have entered the following four values –

10 in A1 (top row)
150 in A100,
75 in A900 and
20 in A1000 (bottom row).

I would like Excel to fill the values in Column B so that they step up in value between B1 where it shows 10 to B100 where it shows 150 (here increasing in value in about every other row) and then decreasing in value from B100 to B900 where it shows 75 (decreasing about every 10 rows), and then decreasing from 75 to 20 between B900 to B1000 (here decreasing in value in about every other row).

I think the logic would go something like;

If this row has a value in Column A, use that value in Column B, otherwise

Using the value and row number of the first row ABOVE which has a value and the value and row number of the first row BELOW which has a value, to calc the value for column B

Take the Value of ABOVE from the value of BELOW and divide by the number of rows between them, multiply that result by the number of rows between the this current row and the row ABOVE and then add the value in ABOVE.

I have a limited grasp of Excel and would appreciate help in understanding how to find the non-empty cells and row numbers or any advice if Im going about it badly.

Best wishes
nicksoph
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Clarification:

Using the value and row number of the first row ABOVE which has a value in column A and the value and row number of the first row BELOW which has a value IN
column A, to calc the value for column B

Take the Value of column A ABOVE from the value of column A BELOW and divide by the number of rows between them, multiply that result by the number of rows between this current row and the row ABOVE and then add the value in column A ABOVE.
 
Last edited:
Upvote 0
If anybody could give me some hints on which commands to use and whether this should be done in the cells or as a function in vba, that would be great.
Thx
Nicksoph
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,988
Members
452,373
Latest member
TimReeks

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