HI,
I am calling the below macros for generating the data-load scripts, all the macros are executing fine, but I am not able to do the exception handling.
This is my master macro which will generate a script based on the columns in A,B,C. The macro should not generate any script if
any one of the cell value is empty. The macro is working fine as expected.
Sub Create_Vscripts()
Dim cell As Range
Dim RNG As Range
Vclear
RR = Cells.Find("*", Cells(Rows.Count, Columns.Count), SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
Set RNG = Range("E5:E154")
For Each cell In RNG
If Not Range("A" & cell.Row) = "" Then
If Not Range("B" & cell.Row) = "" And _
Not Range("C" & cell.Row) = "" Then
cell.Value = "cdrtpy -n " & Replace(Range("C" & cell.Row), ".xml", "") & " -o " _
& Range("A" & cell.Row) & " -f " & Range("B" & cell.Row) & " -s" & " -b"
End If
End If
Next cell
Call Vclear_validation
End Sub
Second macro for clearing the previously generated data.Working as expected.
Sub Vclear()
Range("E5:E154").clear
End Sub
Third macro,is not working as I planned, the macro will generated a .bat file based on the values in the Range("E5:E154").
if the first macro is not generating even a single line, the VScripts.bat should not be generated, but here in this case it is
generating a empty VScripts.bat file. I want to generate this file, only if there is some value present in the range("E5:E154").
Public Sub Vclear_validation()
Const FILENAME = "C:\temp\VScripts.bat"
Dim FileNumber As Long
Dim retVal As Variant
Dim cell As Range
FileNumber = FreeFile
Open FILENAME For Output As #FileNumber
For Each cell In Range("E5:E154")
Print #FileNumber, cell.Text
Next cell
Close #FileNumber
Call Vclear_validation_Log
End Sub
Fourth Macro is also not working properly, the macro should generate Execute_VScripts.bat file, if and only if
the VScripts.bat is present in the C:\temp location, if the file is not present Execute_VScripts.bat should not be generated.
Public Sub Vclear_validation_Log()
Const FILENAME = "C:\temp\Execute_VScripts.bat"
Dim FileNumber As Integer
Dim retVal As Variant
FileNumber = FreeFile
Open FILENAME For Output As #FileNumber
Print #FileNumber, "VScripts.bat > VScripts & .Log"
Close #FileNumber
End Sub
Please give me some hints to handle these exceptions.
Regards,
Swathi
Bookmarks