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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -