excel - Visual Basic Application -


if me pleased ... wrote code in vba count several things , code must highlight cells in excell color didn't , don't know why ...

here code :

private sub commandbutton1_click()     dim studenti integer     dim prezenti integer     dim absenti integer     dim integer      studenti = activesheet.columns("d").specialcells(xltextvalues).rows.count - 1      prezenti = 0     absenti = 0     = 3 studenti + 2         if (cells(i, 4).value = "a")             absenti = absenti + 1             if (optionbutton2.value = true)                 cells(i, 3).font.color = vbgreen 'rgb(255, 0, 0)             end if         end if          if (cells(i, 4).value = "p")             prezenti = prezenti + 1             if (optionbutton1.value = true)                 cells(i, 3).font.color = rgb(0, 255, 0)             end if         end if          if (optionbutton3.value = true)             cells(i, 3).font.color = rgb(0, 0, 0)         end if     next 

the following excel vba code snippet perform core operation, namely: highlighting absenti/presenti (text value "a" or "p" in column d) red/green text color:

private sub commandbutton1_click()     dim studenti integer     dim prezenti integer     dim absenti integer     dim integer      studenti = cells(rows.count, "d").end(xlup).row     = 3 studenti + 2         if (cells(i, 4).value = "a")             cells(i, 4).font.color = rgb(255, 0, 0) 'red         elseif (cells(i, 4).value = "p")             cells(i, 4).font.color = rgb(0, 255, 0) 'green         end if     next end sub 

you can modify further purpose adding business logic (all optionbutton.value, counters, etc.).

hope help. best regards


Comments

Popular posts from this blog

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

node.js - Using Node without global install -

java - JavaScript + Thymeleaf - select onchange -