Jump to content

Autofill a range in excel


Go to solution Solved by water,

Recommended Posts

I am trying to autofill a range. I am getting stuck and I don't understand what I am doing wrong. 

My goal is to auto fill some formulas that are next to a pivot table in columns A-C. 

_Excel_RangeWrite($oNewWorkBook,Default,"2000","D3")
_Excel_RangeWrite($oNewWorkBook,Default,"=(B3-D3)","E3")
_Excel_RangeWrite($oNewWorkBook,Default,"100","F3")
_Excel_RangeWrite($oNewWorkBook,Default,"=(C3-F3)","G3")

$oNewWorkbook.ActiveSheet.Range("D3:G3").Select

With $oNewWorkbook
    .Selection.AutoFill(.Range("D3:G77"),0)
EndWith

The data is not auto filling. 

Hoping someone can point me in the right direction. 

You miss 100% of the shots you don't take. -Wayne Gretzky -Michael Scott

Link to comment
Share on other sites

When writing formulas to a cell you have to set parameter $bValue (Parameter 5) to False.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

  • Solution

This works just fine for me:

#include <Excel.au3>
Global $oExcel = _Excel_Open()
Global $oNewWorkbook = _Excel_BookNew($oExcel)
_Excel_RangeWrite($oNewWorkbook, Default, "2000", "D3")
_Excel_RangeWrite($oNewWorkbook, Default, "=(B3-D3)", "E3")
_Excel_RangeWrite($oNewWorkbook, Default, "100", "F3")
_Excel_RangeWrite($oNewWorkbook, Default, "=(C3-F3)", "G3")

$oRangeRow = $oNewWorkbook.ActiveSheet.Range("D3:G3")
$oRangeRow.AutoFill($oNewWorkbook.ActiveSheet.Range("D3:G77"), 0)

Seems $bValue is not needed. Excel detects formulas and processes them as needed.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

×
×
  • Create New...