excel vba - Check only for weekday values and color using VBA -
i have below vba code color values in col "m" if greater 1 , have text "moved sa (compatibility reduction)".
what want is:
i have dates in col k , code should run on weekday dates , not on weekend dates.
i need add additional text along "moved sa (compatibility reduction)", let's "text 2" , "text 3". so, if col p has either "moved sa (compatibility reduction)" or "text 2" or "text 3", coloring should happen.(it great if possible use wildcards here)
this code should run in sheet "latency"
sub latencymarker() dim r long dim m long on error goto exithere: m = range("m:p").find(what:="*", searchorder:=xlbyrows, searchdirection:=xlprevious).row application.screenupdating = false r = 1 m if range("p" & r) = "moved sa (compatibility reduction)" if range("m" & r) >= 1 range("m" & r).cells.font.colorindex = 3 else range("m" & r).cells.font.colorindex = 0 end if end if next r exithere: application.screenupdating = true end sub
pesky latency sheet not cooperating again? if understood said above correctly following code should trick:
sub latencymarker() dim targetws worksheet dim datarange range dim dataarr() variant dim rowcounter long application.screenupdating = false set targetws = thisworkbook.sheets("latency") set datarange = targetws.range("a1:" & targetws.range(targetws.usedrange.address)(targetws.usedrange.rows.count, targetws.usedrange.columns.count)) set dataarr = datarange rowcounter = 1 ubound(dataarr, 1) if weekday(dataarr(rowcounter, 11), vbmonday) <= 5 if dataarr(rowcounter, 16) = "moved sa (compatibility reduction)" or dataarr(rowcounter, 16) = "text 2" or dataarr(rowcounter, 16) = "text 3" if dataarr(rowcounter, 13) >= 1 datarange(rowcoumter, 13).font.colorindex = 3 else datarange(rowcoumter, 13).font.colorindex = 0 end if end if end if next exithere: application.screenupdating = true end sub
couple things- converted of range data manipulation array data , renamed few of variables more clear-
hope helps.
Comments
Post a Comment