ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   random number in VB (https://www.excelbanter.com/excel-programming/309525-re-random-number-vbulletin.html)

Frank Kabel

random number in VB
 
Hi
n=Int((56-1 + 1) * Rnd + 1)
n=INT(56*rnd+1)


--
Regards
Frank Kabel
Frankfurt, Germany


swatsp0p wrote:
I am trying to write a macro that will rename a tab and change the
color to a random color. The code I have so far is:

ActiveSheet.Name = "my sheet name here"
ActiveWorkbook.Sheets("my sheet name here").Tab.ColorIndex = n

how can I get the 'n' to be a random number? (I am assuming between
1-56?)

TIA



All times are GMT +1. The time now is 06:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com