vba - Excel Cells Formatting with Visual Basic -


i trying put visual basic lines excel file when content of cells of particular column meet specific comparison condition color of corresponding row take predefined color. here testing code:

private sub worksheet_activate()   if activecell = "ok"     range("a13:e13").select     selection.interior      .colorindex = 4      .pattern = xlsolid    end end if end sub 

apparently, has function sheet not 13. also, problem above does't work activecell. there more effective way try that? please!

here answer...

private sub worksheet_activate()   if activecell.value = "ok"      'here activecell cell active,      'but say, want test cells of      'a particular column, in case use      'opt 01:      'if activecell.column = 1 'here asking column                                     'for activecell                                     ' use nested if      'if activecell.value = "ok" ' here if activecell in                                       ' right column , right                                       'value, rows colored     'range("a13:e13").select 'well using this...                              'that want color row of corresponding cell                              'in case can use this:     dim r     dim rng range      r = activecell.row     set rng = range(cells(r, 1), cells(r, 20)) 'you store inside rng cells:                                                'from column 1 = a, row x                                                'to column 20 = t, row x                                                ' x row of activecell                                                'you can change column need     rng.interior 'here can use rng instead selection                       'and affect cells without selecting them.      .colorindex = 4      .pattern = xlsolid    end end if end sub 

or can use conditional formating...

where evaluate contents of cells of column need. think better aproach whay you'r saying.

enter image description here


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -