Code to delete a Line in a another code

H

helmekki

Hi there

Is there a code to Delete a specific line within a VBA Code or withi
another vba code within the same VBAProject ?


Code
-------------------
Sub ChkFileExists()
Dim fs
Dim StrFileName As String

Set fs = CreateObject("Scripting.FileSystemObject")
StrFileName = "C:\Gaber1314.txt"
If fs.FileExists(StrFileName) Then
MsgBox "File Already exixsts", vbInformation, "Execution interrupted"
Else
MsgBox "File Does Not exixsts", vbCritical, "Execution interrupted"
End If

'*I want to delete this line only, using another code in the same VBAProject
Application.Run "Createtxt"

End Sub
-------------------


i looked at :
Pearson Software Consulting, LLC
Programming To The Visual Basic Editor
http://www.cpearson.com/excel/vbe.htm

but could not find waht i need
 
H

Henry

helmekki,

How about another way around the problem?

In a spare cell (say Z99) put "Run"

Sub ChkFileExists()
"
"
"
"
If Range("Z99").Value = "Run" Then
Application.Run"Createtxt"
End If
"
"
"
End Sub

Elsewhere, where you wanted to delete the line, put

Range("Z99").Value = ""

Now that line will run until you change the value in Cell Z99.
It won't be deleted, but it will never be executed again.

Henry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top