excel - Make a cell scroll/marquee text right to left? -
i have cell m2 in excel contains large amount of text. trying figure out way of making text scroll right left continuously.
i have done lot of looking on web can find codes don't make sense me , want try , make simple possible. please show me simple way of getting want.
sub startmarquee() dim smarquee string dim iposition integer smarquee = "this scrolling marquee" me .tbmarquee .text = "" iposition = 1 len(smarquee) .text = .text & mid(smarquee, iposition, 1) application.wait timeserial(hour(now()), minute(now()), second(now()) + 1) next iposition end end 'beep 'application.ontime + timeserial(hour(now()), minute(now()), second(now()) + 2), "startmarquee" end sub
while done inside of loop in subroutine, entire application going locked while loop executing, make extremely unhelpful.
instead think of 1 run of subroutine single iteration. when sub runs want detect in message marquee @ in cell m13, , push message 1 more character. application.ontime
deal schedule subroutine next iteration.
sub domarquee() dim smarquee string dim iwidth integer dim iposition integer dim rcell range dim icurpos integer 'set message displayed in cell smarquee = "this scrolling marquee." 'set cell width (how many characters want displayed @ once iwidth = 10 'which cell doing in? set rcell = sheet1.range("m2") 'determine message. ' instr return position of first ' character current cell value in ' marquee message icurpos = instr(1, smarquee, rcell.value) 'if position 0, there no message, start on ' otherwise, bump message next characterusing mid if icurpos = 0 'start on rcell.value = mid(smarquee, 1, iwidth) else 'bump rcell.value = mid(smarquee, icurpos + 1, iwidth) end if 'set excel run thing again in second or 2 or whatever application.ontime + timevalue("00:00:01"), "domarquee" end sub
put new module, in vbe workbook , run it. if want stop comment out last line application.ontime...
this whole subroutine run in flash, user of workbook shouldn't see running each second bump marquee next character.
Comments
Post a Comment