excel - Randomising a number then displaying a corresponding cell on workbook open -
good afternoon. have tried multiple methods achieve this. in essence code works when run it, however, doesn't seem when workbook opens should. there easier way achieve this?
basically in rows 5-28 there random strings, , want cell g4 show 1 of random strings every time workbook opened.
i think might along right lines, missing obvious?
many thanks
private sub workbook_open() wbopeneventrun = true dim myvalue myvalue = int((28 * rnd) + 5) sheets("hints & tips").range("g4") = cells(myvalue, 7) end sub
try this:
private sub workbook_open() randomize 'as suggested john coleman wbopeneventrun = true dim ws worksheet set ws = sheets("hints & tips") ws.range("g4").value = ws.range("g" & int((23 * rnd()) + 5)).value end sub
Comments
Post a Comment