Sign in to follow this  
Followers 0
iamtheky

Excel Conditional Formatting

3 posts in this topic

#1 ·  Posted (edited)

The below writes a 2d array to an excel sheet, then colors the font of those items in column B with values less than 60. i have these remaining issues:

1) select the entire row when the condition is met, and color the font of the entire row red

2) select the entire contents of column "B" to be conditionally formatted without having to specify row count

and help would be greatly appreciated

#include<excel.au3>

Local $DaysLeft[5][2] = [["LocoDarwin", 59],["Jon", 200],["big_daddy", 3000],["DaleHolm", -4],["GaryFrost", 50]]


$oExcel = _ExcelBookNew(0) ;Create new book, make it visible
_ExcelWriteSheetFromArray($oExcel, $DaysLeft, 1, 1, 0, 0) ;0-Base Array parameters

Global Const $xlCellValue = 1
Global Const $xlless = 6

With $oExcel
.Range("B1:B150").Select
.Selection.FormatConditions.Delete ;Delete Existing FormatConditions
.Selection.FormatConditions.Add($xlCellValue, $xlLess, "60") ;FormatConditions(1)
EndWith

With $oExcel.Selection.FormatConditions(1)
.Font.Bold = True
.Font.Italic = False
.Font.ColorIndex = 3 ;Red
EndWith

_ExcelBookSaveAs($oExcel, @ScriptDir & "" & @Year & @MON & @MDAY & "_daysremaining.xls", "xls", 0, 1) ; Now we save it into the temp directory; overwrite existing file if necessary
_ExcelBookClose($oExcel) ; And finally we close
Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites



$oRange = $oExcel.ActiveCell.EntireColumn

.EntireColumn is the way to go.


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

works for the column range. Thanks.

--I have gone another route now that seems to suffice

#include<excel.au3>

Local $DaysLeft[5][2] = [["LocoDarwin", 59],["Jon", 200],["big_daddy", 3000],["DaleHolm", -4],["GaryFrost", 50]]

$oExcel = _ExcelBookNew(0) ;Create new book, make it visible
_ExcelWriteSheetFromArray($oExcel, $DaysLeft, 1, 1, 0, 0) ;0-Base Array parameters

For $i = 1 to 999
$cell = _ExcelReadCell ($oExcel , $i , 2)
If $cell = "" Then ExitLoop
If $cell < "60" Then
$oExcel.range("A" & $i & ":B" & $i).select
$oExcel.selection.Font.ColorIndex = 3
$oExcel.selection.Font.Bold = True
endif
next

_ExcelBookSaveAs($oExcel, @ScriptDir & "" & @Year & @MON & @MDAY & "_daysremaining.xls", "xls", 0, 1) ; Now we save it into the temp directory; overwrite existing file if necessary
_ExcelBookClose($oExcel) ; And finally we close
Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • LoneWolf_2106
      By LoneWolf_2106
      Hi everybody,
      i have to store an entire row of a Excel workbook into an array.  The row index is stored in a variable.
      How can i do it?
      Thanks in advance for your support.
    • LoneWolf_2106
      By LoneWolf_2106
      Hi everybody,
      i have to write a value into an excel column.
      I know where it starts from, but i don't know what the end is, last non-empty cell.
      How can i get the number of last non-empty cell?
      Thanks in advance.
      Regards 
    • Nareshm
      By Nareshm
      Hi All,
      I have excel file like this
      and i want to cut cell/text from excel to other software.

       
      I have to cut the cell of B column one by one and past into other software
      If Winexists("No Data Found")
      then restore cuted cell and goto next/down side cell
      How to do it ?
    • water
      By water
      Extensive library to control and manipulate Microsoft Excel charts.
      Theads: General Help & Support - Example Scripts
      BTW: If you like this UDF please click the "I like this" button. This tells me where to next put my development effort

      KNOWN BUGS (last changed: 2017-07-21)
      None. The COM error handling related bugs have been fixed.
       
    • Mag91
      By Mag91
      Hey Community,
      cause im too new in the Auto it world i will try it with the your help. hopefully.
      I woud like to know how i can handle my Problem.
      ----
      I have a Excel Data with 362 random numbers.
      For Example:
      1166642335374 1172899897343
      .....
      this numbers are a part of the filepath ...example
      D:\Projekte\1166_64233_5374
      as u can see its the first number of the Excel data. After the first 4 numbers it shoud make a "_" than another 5 "_"
      This is my first question. How can i handle this to make it Shell execute.
       
      --------
      Second question:
      If i am in the path.
      For Example:
      D:\Projekte\1166_64233_5374
      the code shoud search for specific PDF Files.
      They are named like: 0050569E364B1ED79B900F73E62660EC.pdf
      the first 15 letters are always the same
      0050569E364B1ED
      when he found this data he has to copy it on a Folder on the Desktop.
      (There can also be 2 or 3 pdfs in one Folder with this letters)
      ----
      Please give me some help :-)