Halting macro
Hi Board,
I have written this macro which on started pastes the data in r35c27 and calculates the formulaes and checks if a1 and a2 values are >=1, then it creates a file in specified folder with the values of a1 or a2 as required and sends a key storke Y or N to my backoffice software. this code has been written by me reading/uderstanding other codes.
This code works fine but some times doesnot give me desired results.Can anybody help with a correct way to write this code in a proffesional touch.
thanx in advance.
bob
Hi Board,
I have written this macro which on started pastes the data in r35c27 and calculates the formulaes and checks if a1 and a2 values are >=1, then it creates a file in specified folder with the values of a1 or a2 as required and sends a key storke Y or N to my backoffice software. this code has been written by me reading/uderstanding other codes.
This code works fine but some times doesnot give me desired results.Can anybody help with a correct way to write this code in a proffesional touch.
thanx in advance.
bob
Code:
Sub Macro1()
Application.Goto Reference:="R35C27"
ActiveSheet.Paste
If ActiveWorkbook.Worksheets(1).Range("a1").Value >= 1 Then
Const sSheet As String = "Sheet1"
Dim wsh As Excel.Worksheet
Dim sPath As String
Set wsh = ThisWorkbook.Worksheets(sSheet)
With wsh
sPath = "c:\routersales\rs.txt"
Open sPath For Output As #1
Print #1, .Range("A1").Value
Close #1
Application.SendKeys ("%{tab}")
Application.SendKeys ("{y}")
End With
Else
If ActiveWorkbook.Worksheets(1).Range("a2").Value >= 1 Then
Set wsh = ThisWorkbook.Worksheets(sSheet)
With wsh
sPath = "D:\modemsales\ms.txt"
Open sPath For Output As #1
Print #1, .Range("A2").Value
Close #1
Application.SendKeys ("%{tab}")
Application.SendKeys ("{y}")
End With
Else
Application.Goto Reference:="R35C30"
ActiveSheet.Paste
Macro3
End If
End If
End Sub
Sub Macro3()
Application.SendKeys ("%{tab}")
Application.SendKeys ("{N}")
End Sub
Last edited by a moderator: