Jump to content

_ExcelWriteCell using A1\R1C1 referencing


Recommended Posts

Hi guys

I am trying to write to a cell using a loop with A1 cell referencing, i.e

_ExcelWriteCell($oExcel, "PASSED", $i, "D7")

However nothing is being written to the cell. It will allow me to use:

_ExcelWriteCell($oExcel, "PASSED", $i, 7)

But this only allows me to write from column 7. Is there any way to write from cell D7 using A1 referencing or 7,4 using R1C1.

Thank you

Edited by syno
Link to comment
Share on other sites

Hi guys

I am trying to write to a cell using a loop with A1 cell referencing, i.e

_ExcelWriteCell($oExcel, "PASSED", $i, "D7")

However nothing is being written to the cell. It will allow me to use:

_ExcelWriteCell($oExcel, "PASSED", $i, 7)

But this only allows me to write from column 7. Is there any way to write from cell D7 using A1 referencing or 7,4 using R1C1.

Thank you

The A1 reference "D7" is column "D" (the fourth column) on row 7. So you could either use "D7" for A1 format and leave the column parameter off, or use "7, 4" for R1C1 format. You can't mix them.

Since you want to iterate at least one of the values with a variable, the later is more appropriate:

$r = 7; row 7
$c = 4; column D
_ExcelWriteCell($oExcel, "PASSED", $r, $c)

:D

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

The A1 reference "D7" is column "D" (the fourth column) on row 7. So you could either use "D7" for A1 format and leave the column parameter off, or use "7, 4" for R1C1 format. You can't mix them.

Since you want to iterate at least one of the values with a variable, the later is more appropriate:

$r = 7; row 7
$c = 4; column D
_ExcelWriteCell($oExcel, "PASSED", $r, $c)

:D

Hi

Thanks for your help with this. If I use;

_ExcelWriteCell($oExcel, "PASSED", $i, 4, 7)

I get an error message: 'ERROR: _ExcelWriteCell() called with wrong number of args.' and 'Incorrect number of parameters in function call.:'

However if I use:

_ExcelWriteCell($oExcel, "PASSED", $i, "D7")

Nothing gets written to excel at all, this is also true if I use a different cell reference like "E8". I can understand why 4,7 does not work with that extra iteration ($i). But I do not know why "D7" does not work. It just seems to ignore it completely and I get no error messages.

Thank you

Link to comment
Share on other sites

Hi,

i think you haven't understand PsaltyDS.

As he wrote:

The A1 reference "D7" is column "D" (the fourth column) on row 7. So you could either use "D7" for A1 format and leave the column parameter off, or use "7, 4" for R1C1 format. You can't mix them.

My code:

#include <Excel.au3>

$oExcel = _ExcelBookNew()

$c = 4; column D

For $i = 1 To 7

_ExcelWriteCell($oExcel, "PASSED", $i, $c)

Next

writes PASSED in the fourth column on row 1 to 7. So check your code again.

;-))

Stefan

Link to comment
Share on other sites

Hi,

i think you haven't understand PsaltyDS.

As he wrote:

The A1 reference "D7" is column "D" (the fourth column) on row 7. So you could either use "D7" for A1 format and leave the column parameter off, or use "7, 4" for R1C1 format. You can't mix them.

My code:

#include <Excel.au3>

$oExcel = _ExcelBookNew()

$c = 4; column D

For $i = 1 To 7

_ExcelWriteCell($oExcel, "PASSED", $i, $c)

Next

writes PASSED in the fourth column on row 1 to 7. So check your code again.

;-))

Stefan

Thank you for your response but I would like to start writing to row 7 and not row 1...

Link to comment
Share on other sites

Thank you for your response but I would like to start writing to row 7 and not row 1...

So just change For loop:

#include <Excel.au3>

$oExcel = _ExcelBookNew()

$c = 4; column D

For $i = 7 To 15

_ExcelWriteCell($oExcel, "PASSED", $i, $c)

Next

writes PASSED in the fourth column on row 7 to 15

;-((

Link to comment
Share on other sites

So just change For loop:

#include <Excel.au3>

$oExcel = _ExcelBookNew()

$c = 4; column D

For $i = 7 To 15

_ExcelWriteCell($oExcel, "PASSED", $i, $c)

Next

writes PASSED in the fourth column on row 7 to 15

;-((

Hi 99ojo

I cannot change the FOR loop as it makes up an integral part of my code...It seems that I can only write to row one when I am using this FOR loop and not any other rows??????

Thanks

Link to comment
Share on other sites

Hi 99ojo

I cannot change the FOR loop as it makes up an integral part of my code...It seems that I can only write to row one when I am using this FOR loop and not any other rows??????

Thanks

What? :D

That made no sense at all. You were just shown a loop that writes to a series of different rows. What is it about your original loop that can't be changed?

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

What? :D

That made no sense at all. You were just shown a loop that writes to a series of different rows. What is it about your original loop that can't be changed?

:D

Hi,

He should show us his code, so we can see, what he's talking about. He may need a double

For Loop, one for the rows, one for the columns??!!??

Stefan

;) (as well)

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...