ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   InsertLines Syntax (https://www.excelbanter.com/excel-programming/413686-insertlines-syntax.html)

Stephen Newman[_2_]

InsertLines Syntax
 
I want to add a variable to an inserted line, but I can't seem to get
the syntax right.

I have for instance:

With TempForm.CodeModule
X = .CountOfLines
Dim y

for y = 1 to 10
.InsertLines X + y, "MsgBox ""This is message "" & y"
next y

End With

The code is inserted into the module, but this is the result for each
MsgBox:

MsgBox "This is message " & y


I just can't seem to get the variable to be part of the code.

Any help will be appreciated.

Tim Zych

InsertLines Syntax
 
..InsertLines x + y, "MsgBox ""This is message "" & " & y

--
Tim Zych
www.higherdata.com
Compare data in Excel and find differences with Workbook Compare
A free, powerful, flexible Excel utility


"Stephen Newman" wrote in message
...
I want to add a variable to an inserted line, but I can't seem to get
the syntax right.

I have for instance:

With TempForm.CodeModule
X = .CountOfLines
Dim y

for y = 1 to 10
.InsertLines X + y, "MsgBox ""This is message "" & y"
next y

End With

The code is inserted into the module, but this is the result for each
MsgBox:

MsgBox "This is message " & y


I just can't seem to get the variable to be part of the code.

Any help will be appreciated.




Stephen Newman[_2_]

InsertLines Syntax
 
On Mon, 7 Jul 2008 20:34:24 -0700, "Tim Zych"
<tzych@NOSp@mE@RTHLINKDOTNET wrote:

It never occurred to me that everything on the line beyond the comma
would be inserted. I threw a lot of "Expected End Of Statement" errors
trying to keep everything within the quotes. Thank you.

.InsertLines x + y, "MsgBox ""This is message "" & " & y



All times are GMT +1. The time now is 02:49 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com