Jump to content

<Noobie>Excel first script


zsoltm
 Share

Recommended Posts

Use this line I already posted:

_Excel_RangeWrite($oWorkbook, Default, "=Mod(A2;2)", "$B2:B" & $oWorkbook.Activesheet.UsedRange.Rows.Count, False) ; Insert the formula (modulo) in column B

replace "=Mod(A2;2)" with your formula. The example will copy the formula to all used cells in column B. As all cell referenced in the formula are relative the copy operation will adjust the reference.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

its doesnt seems to me to doing anything...

... doesn't really help me to find the cause of the problem ;)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

How can I make it automatically determine the number of the rows (in the excel documents) to be able to set the parameters for the script?

#include <Excel Rewrite.au3>


Global $i = 1
Global $selector = '"of","restaurant","courtyard","licenced","landscapes","travel","specialist","testing","relay","imaging","environmental","associates"'
Global $sFormula = "=IF(OR(ISNUMBER(search("" ""&{" & $selector & "}&"" "","" ""&b" & $i & "&"" ""))),""YES"",""NO"")"


Global Const $xlCellTypeVisible = 12 ; All visible cells
Global $aData = $sFormula
Global $oExcel = _Excel_Open() ; Connect to Excel or open a new instance
Global $oWorkbook = _Excel_BookNew($oExcel) ; Create a new workbook


For $i = 0 To 100 step 1
Next


_Excel_RangeWrite($oWorkbook, Default, $aData, "A1:A100");
MsgBox(0, "RangeWrite Data", @error)
_Excel_FilterSet($oWorkbook, Default, $oWorkbook.Activesheet.UsedRange, 1, "NO") ; Only display even numbers
MsgBox(0, "FilterSet", @error)
Global $oRange = $oWorkbook.Activesheet.UsedRange.SpecialCells($xlCellTypeVisible) ; Only select visible rows
MsgBox(0, "Visible cells", @error)
$oRange.EntireRow.Delete ; delete visible rows
Link to comment
Share on other sites

The number of used rows can be determined by

$oWorkbook.Activesheet.UsedRange.Rows.Count

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

#include <Excel Rewrite.au3>


Global $i = 1
Global $selector = '"hairdressing","ltd","services","furnitures","co","inn","national","testing","superstore","shop","society","club"'
Global $sFormula = "=IF(OR(ISNUMBER(search("" ""&{" & $selector & "}&"" "","" ""&b" & $i & "&"" ""))),""YES"",""NO"")"




Global Const $xlCellTypeVisible = 12 ; All visible cells
Global $aData = $sFormula
Global $oExcel = _Excel_Open() ; Connect to Excel or open a new instance
Global $oWorkbook = _Excel_BookOpen;_Excel_BookNew($oExcel)


Global $row = $oWorkbook.Activesheet.UsedRange.Rows.Count


_Excel_RangeInsert($oWorkbook.Activesheet, "A:A", $xlShiftToRight) ; Insert column B and shift existing data to the right




For $i = 0 To $row step 1
Next




_Excel_RangeWrite($oWorkbook, Default, $aData, "A1:A"$row);
MsgBox(0, "RangeWrite Data", @error)
_Excel_FilterSet($oWorkbook, Default, $oWorkbook.Activesheet.UsedRange, 1, "Yes") ; Only display even numbers
MsgBox(0, "FilterSet", @error)
Global $oRange = $oWorkbook.Activesheet.UsedRange.SpecialCells($xlCellTypeVisible) ; Only select visible rows
MsgBox(0, "Visible cells", @error)
$oRange.EntireRow.Delete ; delete visible rows

I made a quick example. is something wrong with my codes. there is 70 row so the $row should be = 70. but now it dont want to fill in my formula

http://speedy.sh/wJrtm/example.xlsx
Link to comment
Share on other sites

Will do some tests as soon as I return to my office.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

The following example works but Excel seems to have a problem with your formula. Can you try to manually insert the formula?

#include <Excel Rewrite.au3>

Global $selector = '"hairdressing","ltd","services","furnitures","co","inn","national","testing","superstore","shop","society","club"'
;Global $sFormula = "=IF(OR(ISNUMBER(search("" ""&{" & $selector & "}&"" "","" ""&b" & $i & "&"" ""))),""YES"",""NO"")"
Global $sFormula = "=WENN(ODER(ISTZAHL(SUCHE("" ""&{" & $selector & "}&"" "","" ""&b" & $i & "&"" ""))),""YES"",""NO"")"
ConsoleWrite($sFormula & @LF)

Global Const $xlCellTypeVisible = 12 ; All visible cells
Global $aData = $sFormula
Global $oExcel = _Excel_Open() ; Connect to Excel or open a new instance
MsgBox(0, "Open", @error)
Global $oWorkbook = _Excel_BookOpen($oExcel, "C:\temp\example.xlsx")
MsgBox(0, "Bookopen", @error)
Global $row = $oWorkbook.Activesheet.UsedRange.Rows.Count
_Excel_RangeInsert($oWorkbook.Activesheet, "A:A", $xlShiftToRight) ; Insert column B and shift existing data to the right
MsgBox(0, "RangeInsert", @error)
_Excel_RangeWrite($oWorkbook, Default, "=MOD(A1;2)", "A1:A" & $row, False)
;_Excel_RangeWrite($oWorkbook, Default, $sFormula, "A1:A" & $row, False)
MsgBox(0, "RangeWrite Data", @error)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...