Big data set excel

3 posts in this topic

#1 ·  Posted (edited)

Hi Guys,

Appreciate the help!

Without getting into details... basically,

So, I have a large data set (about 10k rows, and 10 columns).

I need autoit to select A2, then paste it into an external program.

then, i need it to select B2 and paste it into another field, then C2, into another, D2 into another etc.

Then move onto row 3 and repeat.

Is there an easier way to cycle the row numbers in the loop aside from what I have done before on smaller data sets (ie. <30) where $run is the reference to the addition. Coding up 20k of if $run = blar then blar blar blar seems a little tedious.

I used _Excel_RangeCopyPaste before as shown below.... i am also not sure if some of my code is not necessary. Any help on that would be appreciated also.


Thanks for your help!

#include <Excel.au3>
;assist variables etc to specific excel books etc.

Func cellselect()

if $run = 1 then
$data1 = A2
$data2 = B2
$data3 = C2

if $run = 2 then
$data1 = A3
$data2 = B3
$data3 = C3


while 1
$run = $run+1
winactivate("spreadsheet title that is open already")
local $oRange = $oWorkbook.ActiveSheet.Range($data1)
_Excel_RangeCopyPaste($oWorkbook.ActiveSheet, $oRange, Default)
Winactivate ("other program")

local $oRange = $oWorkbook.ActiveSheet.Range($data2)
_Excel_RangeCopyPaste($oWorkbook.ActiveSheet, $oRange, Default)
Winactivate ("other program")
;do stuff here with data ,3,4,5 etc, flicking between excel and program, pasting specific data fields and then exit



Edited by MrCheese
adding explanation and more code

Share this post

Link to post
Share on other sites

I think I nailed the sequential row loop.

thanks to the UDF example!!

Any ideas about how to do a sequential column grab?

Would you need to manually map A = 1, B = 2 etc?

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open Workbook 1
Local $oWorkbook1 = _Excel_BookOpen($oExcel, @ScriptDir & "/Book1.xlsx", True)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example", "Error opening workbook '" & @ScriptDir & "Book1.xlsx'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
$run = 0
$rrdif = 1
$rowpaste = 3

; *****************************************************************************
; Copy a range with 3 rows and 2 columns on the active worksheet.
; Pass the source range as object.
; *****************************************************************************
While $run <$ttlrun
    $run = $run + 1
    $row = $run + $rrdif
    $row2 = $run + $rowpaste
    Local $oRange = $oWorkbook1.ActiveSheet.Range("A" & $row)
    _Excel_RangeCopyPaste($oWorkbook1.ActiveSheet, $oRange, "K" & $row2)

    Local $oRange = $oWorkbook1.ActiveSheet.Range("B" & $row)
    _Excel_RangeCopyPaste($oWorkbook1.ActiveSheet, $oRange, "L" & $row2)

    Local $oRange = $oWorkbook1.ActiveSheet.Range("C" & $row)
    _Excel_RangeCopyPaste($oWorkbook1.ActiveSheet, $oRange, "M" & $row2)


Share this post

Link to post
Share on other sites

It takes some tim to process 10000 rows the way you do it. Is speed an issue for your script? Means: The faster the better?

My UDFs and Tutorials:


Active Directory (NEW 2017-04-18 - Version - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version - Download - General Help & Support

ADO - Wiki


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

  • Similar Content

    • LoneWolf_2106
      By LoneWolf_2106
      Hi all,
      i have an empty csv file, i have a non formatted text file.
      What do i want to do?
      I want to automate the process "get external data" in Excel, i want to import the data from the text file and basically create a csv file with a specific character encoding.
      Is it possible with AutoIT?
    • breakbadsp
      By breakbadsp
      I  want to create a excel file from my script if it does not exist.
      _ExcelBookOpen throws error=2 if file does not exist, after this error i want to create new file at this point.
      can i use _FileCreate()?
      _Logger($sLogPath, "{INFO}------: Opening Excel File: " & $sExcelPath& "") While 1 Local $oExcelTestResult = _ExcelBookOpen($sExcelPath) If @error = 2 Then If not _FileCreate($sResExcelPath) Then MsgBox(0, "Error", "Error In Opening REsult Excel File: Error: " & String(@error)) _Logger($sLogPath, "{ERROR}------: Result Excel File does not exist.. tried to create new but :ERROR : " & String(@error) & "") ExitLoop Else _Logger($sLogPath, "{INFO}------: Result Excel File does not exist.. **Created New**: ") EndIf Else ExitLoop EndIf WEnd  
    • 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.
    • 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 ?