+ Reply to Thread
Results 1 to 5 of 5

Macro to execute .bat file depending on cell values

Hybrid View

semajjames Macro to execute .bat file... 10-18-2015, 07:20 AM
Kenneth Hobson Re: Macro to execute .bat... 10-18-2015, 09:08 AM
semajjames Re: Macro to execute .bat... 10-18-2015, 12:01 PM
semajjames Re: Macro to execute .bat... 10-18-2015, 12:27 PM
Kenneth Hobson Re: Macro to execute .bat... 10-18-2015, 02:37 PM
  1. #1
    Forum Contributor
    Join Date
    11-14-2014
    Location
    uk
    MS-Off Ver
    Excel 2010
    Posts
    100

    Macro to execute .bat file depending on cell values

    I need a macro that will execute a .bat file on my pc but certain criteria has to be met for this to happen ,,,the file needs to be executed only if :-

    A1 = 0

    A2 = A3

    A2 >=A4+A5

    Is this possible

    cheers

  2. #2
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Macro to execute .bat file depending on cell values

    Sub ken()
        Dim s As String
        s = "x:\bats\ken.bat"
        With Worksheets("Sheet1")
            If .Range("A1").Value = 0 And .Range("A2").Value = .Range("A3").Value And _
                .Range("A2").Value >= .Range("A4").Value + .Range("A5").Value Then _
                Shell """" & s & """", vbHide
        End With
    End Sub

  3. #3
    Forum Contributor
    Join Date
    11-14-2014
    Location
    uk
    MS-Off Ver
    Excel 2010
    Posts
    100

    Re: Macro to execute .bat file depending on cell values

    thanks
    could i also use this method to say open a note pad file ect ?

  4. #4
    Forum Contributor
    Join Date
    11-14-2014
    Location
    uk
    MS-Off Ver
    Excel 2010
    Posts
    100

    Re: Macro to execute .bat file depending on cell values

    thanks
    could i also use this method to say open a note pad file ect ?

  5. #5
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Macro to execute .bat file depending on cell values

    Yes.
    Shell "cmd /c Notepad " & """" & "C:\myfiles\Excel\txtfiles\MyFile.txt" & """", vbHide

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Macro to Import Text file in a Cell depending on the current day of the year.
    By prkhan56 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-22-2015, 08:16 AM
  2. [SOLVED] VBA Macro to Insert Row Depending on Two Cell Values in seperate Columns
    By SysEng in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-28-2014, 12:41 PM
  3. Macro to insert cell values in another sheet depending on value and format
    By adw223 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-27-2013, 03:57 PM
  4. Macro to Copy Paste Rows Depending on a Cell Value and show values against each row
    By prkhan56 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-29-2013, 11:41 AM
  5. Need a macro to execute DOS command( dir /b /a-d > file.txt ) from excell.
    By anto_01 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-12-2012, 06:02 PM
  6. Replies: 1
    Last Post: 09-04-2012, 05:49 AM
  7. [SOLVED] Execute .bat file using Excel Macro
    By viksch in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-03-2012, 05:02 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1