Macro Modifcation if file is not present macro will not do anything
Hi
Code:
Sub STEP12()
Dim Val As String, wb1 As Workbook, wb2 As Workbook, srcWS As Worksheet, desWS As Worksheet
Dim i As Long, v1 As Variant, v2 As Variant, rngList As Object
Set wb1 = Workbooks.Open("C:\Users\WolfieeeStyle\Desktop\ap.xls")
Set wb2 = Workbooks.Open("C:\Users\WolfieeeStyle\Desktop\Files\AlertCodes.xlsx")
Set desWS = wb1.Worksheets.Item(1)
Set srcWS = wb2.Worksheets.Item(1)
v1 = desWS.Range("E2", desWS.Range("E" & desWS.Rows.Count).End(xlUp)).Value
v2 = srcWS.Range("A2", srcWS.Range("A" & srcWS.Rows.Count).End(xlUp)).Resize(, 2).Value
Set rngList = CreateObject("Scripting.Dictionary")
For i = 1 To UBound(v1, 1)
Val = v1(i, 1)
If Not rngList.exists(Val) Then
rngList.Add Key:=Val, Item:=i + 1
End If
Next i
For i = 1 To UBound(v2, 1)
Val = v2(i, 1)
If rngList.exists(Val) Then
desWS.Cells(rngList(Val), 25) = v2(i, 2)
End If
Next i
Application.ScreenUpdating = True
wb1.Save
wb2.Save
wb1.Close
wb2.Close
End Sub
This is the macro
I need a slight change in it
If ap.xls files is present then only this macro will work & if ap.xls file is not present then it should not do anything
I can use on error resume next code in this macro but u have suggested not to use that
So i need help for the same
Conditionally Run & move the .bat file shortcut(i.e .lnk file) by vba macro
Hi Experts,
Code:
Public Declare PtrSafe Function ShellExecute _
Lib "shell32.dll" _
Alias "ShellExecuteA" ( _
ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) _
As Long
Sub FFF()
Dim strFileName As String
Dim strFileExists As String
strFileName = "C:\Users\WolfieeeStyle\Desktop\Close Excel.lnk"
strFileExists = Dir(strFileName)
If strFileExists = "" Then
Set FSO = CreateObject("scripting.filesystemobject")
FSO.MoveFile Source:="C:\Users\WolfieeeStyle\Desktop\Close Excel.lnk", Destination:="C:\Users\WolfieeeStyle\Desktop\WolfieeeStyle\9.15\"
ShellExecute 0, "OPEN", "C:\Users\WolfieeeStyle\Desktop\WolfieeeStyle\9.15\Close Excel.lnk", "", "", 1
Else
End If
End Sub
I am looking for a macro that will
First Check Close Excel.lnk is located or not & if it is located then move that Close Excel.lnk to C:\Users\WolfieeeStyle\Desktop\WolfieeeStyle\9.15\ & then run that Close Excel.lnk
& If the Close Excel.lnk file is not located then do nothing
This macro is not working i think it has issues
Thnx
https://www.vbforums.com/showthread....)-by-vba-macro
https://chandoo.org/forum/threads/co...a-macro.44815/
https://www.excelforum.com/excel-pro...ml#post5378034
https://www.ozgrid.com/forum/index.p...-by-vba-macro/