XLSetCell not working for me
Moderators: JRL, Dorian (MJT support)
XLSetCell not working for me
The 'XLSetCell' statement in the following code is not working for me. I want to insert a 'C' in the 4th column but the column remains blank.
I am using Excel 2007.
XLOpen>MyFil,1,XLBook
Let>XL_Loop=1
Let>XL_Row=2
Repeat>XL_Loop
XLGetCell>XLBook,Sheet1,XL_Row,1,XL_C1
XLGetCell>XLBook,Sheet1,XL_Row,2,XL_C2
XLGetCell>XLBook,Sheet1,XL_Row,3,XL_C3
XLGetCell>XLBook,Sheet1,XL_Row,4,XL_C4
MidStr>XL_C3,1,1,XL_C3_1
Let>VBEval_In=UCase("%XL_C3_1%")
VBEval>%VBEval_In%,XL_C3_1
MidStr>XL_C3,2,1,XL_C3_2
Let>VBEval_In=UCase("%XL_C3_2%")
VBEval>%VBEval_In%,XL_C3_2
If>{(%XL_C1%="") or (%XL_C2%="")}
Let>XL_Loop=0
Else
If>XL_C3_1=Y
//GoSub>NDC_Updt,XL_C1,XL_C2
XLSetCell>XLBook,Sheet1,XL_Row,4,C
Let>XL_Row=XL_Row+1
Endif
If>XL_C3_2=P
GoSub>GetOk
Endif
If>XL_C3_2=S
Let>XL_Loop=0
Endif
Endif
Until>XL_Loop,0
Suggestions / Ideas?
Thanks!
I am using Excel 2007.
XLOpen>MyFil,1,XLBook
Let>XL_Loop=1
Let>XL_Row=2
Repeat>XL_Loop
XLGetCell>XLBook,Sheet1,XL_Row,1,XL_C1
XLGetCell>XLBook,Sheet1,XL_Row,2,XL_C2
XLGetCell>XLBook,Sheet1,XL_Row,3,XL_C3
XLGetCell>XLBook,Sheet1,XL_Row,4,XL_C4
MidStr>XL_C3,1,1,XL_C3_1
Let>VBEval_In=UCase("%XL_C3_1%")
VBEval>%VBEval_In%,XL_C3_1
MidStr>XL_C3,2,1,XL_C3_2
Let>VBEval_In=UCase("%XL_C3_2%")
VBEval>%VBEval_In%,XL_C3_2
If>{(%XL_C1%="") or (%XL_C2%="")}
Let>XL_Loop=0
Else
If>XL_C3_1=Y
//GoSub>NDC_Updt,XL_C1,XL_C2
XLSetCell>XLBook,Sheet1,XL_Row,4,C
Let>XL_Row=XL_Row+1
Endif
If>XL_C3_2=P
GoSub>GetOk
Endif
If>XL_C3_2=S
Let>XL_Loop=0
Endif
Endif
Until>XL_Loop,0
Suggestions / Ideas?
Thanks!
Put strings in quotes
Hi jbas,
Try:
Gale
Try:
Code: Select all
//Does not need quotes
//Does need 6th param - the result variable.
XLSetCell>XLBook,Sheet1,XL_Row,4,C,result
//small wait so you can see the text added to the cell
wait>1
Last edited by gdyvig on Tue Jun 22, 2010 2:48 pm, edited 1 time in total.
I modified my previous post.
I removed the quotes around the C.
I also added the 6th param to store the result.
When I omitted the result variable, no text was added to the cell.
The user guide examples do not show the result variable.
I also cound not get XLSave to work. My xls file was in SCRIPT_DIR.
Gale
I removed the quotes around the C.
I also added the 6th param to store the result.
When I omitted the result variable, no text was added to the cell.
The user guide examples do not show the result variable.
I also cound not get XLSave to work. My xls file was in SCRIPT_DIR.
Gale
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Sorry.
XlSetCell requires a result variable:
XLSetCell>xlBook,Sheet1,28,2,ABC,res
If successful the result var will hold 0, otherwise if an error occurred it will store the error message.
This works fine for me. Looks like the help file is wrong.
I've also just seen that XLSave is only working where the filename is literal, so will fail if there's a variable (e.g. SCRIPT_DIR) in the filename.
Will get both sorted asap.
XlSetCell requires a result variable:
XLSetCell>xlBook,Sheet1,28,2,ABC,res
If successful the result var will hold 0, otherwise if an error occurred it will store the error message.
This works fine for me. Looks like the help file is wrong.
I've also just seen that XLSave is only working where the filename is literal, so will fail if there's a variable (e.g. SCRIPT_DIR) in the filename.
Will get both sorted asap.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Yeow... I missed that omission in the Help file... as I started with your example macros and in there, you included the result variable... so I was able to use this command without trouble. My compliments by the way, this method is much faster and more reliable than the code I was previously using to enter values into spreadsheets.mtettmar wrote:Sorry.
XlSetCell requires a result variable:
XLSetCell>xlBook,Sheet1,28,2,ABC,res
If successful the result var will hold 0, otherwise if an error occurred it will store the error message.
This works fine for me. Looks like the help file is wrong.
Question: Doesn't the XLSetCell> command complain if you are one parameter short i.e. there are 5 parameters supplied instead of 6? If not then it should.
Thanks Marcus and take caremtettmar wrote:I've also just seen that XLSave is only working where the filename is literal, so will fail if there's a variable (e.g. SCRIPT_DIR) in the filename.
Will get both sorted asap.
jpuziano
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -

- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Should do, but obviously doesn't.Question: Doesn't the XLSetCell> command complain if you are one parameter short i.e. there are 5 parameters supplied instead of 6? If not then it should.
The code builder, and syntax highlighter are correct. Only the help file and the parameter count warning seem to be wrong.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?