Anyone know how to create a random color hex ...

(Grant Stead) #1

Anyone know how to create a random color hex code? Preferably unique to the table…

(Tony Fader) #2

@Grant_Stead I think this will work in excel/sheets:

=DEC2HEX(RANDBETWEEN(0, 256^3), 6)

Might be a good starting place.

(Stephen Mattison) #3

@Grant_Stead How are you using random colors?

(Grant Stead) #4

In case anyone stumbles on this, here’s what I did. I’ve got appsheet dropping in an initial RANDBETWEEN(0, 16777215) so that it stays fixed… Then I’ve got an array formula on the google sheets side to convert it to HEX color code. =ARRAYFORMULA(IF(ROW(AN1:AN)=1,“people_hex_color”, IF(ISBLANK(AN1:AN),DEC2HEX(AN1:AN, 6))))

(Gil Littman [AppSheet]) #5

@tony @Grant_Stead Should be: =DEC2HEX(RANDBETWEEN(0, 256^3 - 1), 6) Since =DEC2HEX(256^3, 6) is invalid (extremely unlikely to happen)

(Grant Stead) #6

@Gil_Littman_AppSheet is there an option on the appsheet side?

(Gil Littman [AppSheet]) #7

@Grant_Stead Not as far as I know.

(Grant Stead) #8

@Gil_Littman_AppSheet Thanks!

(Grant Stead) #9

@Stephen_Mattison So, long story short. With this… -

I can make custom icons, by building a concatenated URL. This also gives me the ability to have unique colors for each person, that way if they make comments, etc. You can tell whom it is at a glance.

(Stephen Mattison) #10

@Grant_Stead Nice work, me likey! TY!

(Grant Stead) #11

@Gil_Littman_AppSheet Why the -1?

(Grant Stead) #12

@Gil_Littman_AppSheet Nevermind… I get it LOL… 256 of each red/green/blue… starting at 0 not 1… bang.