How to write a code for clicking "No" on the message box below

ExcelPupper

Board Regular
Joined
Mar 2, 2020
Messages
102
Office Version
  1. 2019
Platform
  1. Windows
1597135770306.png


Hi, I have here a message prompt everytime I run my code below.
Is there a way to add a line of code that clicks the "No" button so it won't prompt again next time I run this code?


VBA Code:
Sub DataDownload()
'
'Copy downloaded data from product costing system

Dim lr As Long

    Workbooks.OpenText Filename:="C:\Temp\DataDownload.xls", Origin:=437 _
        , Startrow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
        ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=True, Comma:=False, _
        Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2, 1), Array( _
        3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), Array(9, 1), Array(10 _
        , 1), Array(11, 1), Array(12, 1), Array(13, 1), Array(14, 1), Array(15, 1), Array(16, 1), _
        Array(17, 1), Array(18, 1), Array(19, 1), Array(20, 1), Array(21, 1), Array(22, 1), Array( _
        23, 1), Array(24, 1)), TrailingMinusNumbers:=True
   
    lr = Range("A" & Rows.Count).End(xlUp).Row
   
   
    Range("A1:X" & lr).Select
    Selection.Copy
    Windows(ThisWorkbook.Name).Activate
    Sheets(1).Range("A1").PasteSpecial Paste:=xlPasteValues
    Workbooks("AccountingDownload.xls").Close SaveChanges:=False
   
   
End Sub
 

Some videos you may like

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

ChrisFoster

Board Regular
Joined
Jun 21, 2019
Messages
131
Office Version
  1. 365
Platform
  1. Windows
Try this.

VBA Code:
Sub DataDownload()
'
'Copy downloaded data from product costing system

Dim lr As Long

    Workbooks.OpenText Filename:="C:\Temp\DataDownload.xls", Origin:=437 _
        , Startrow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
        ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=True, Comma:=False, _
        Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2, 1), Array( _
        3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), Array(9, 1), Array(10 _
        , 1), Array(11, 1), Array(12, 1), Array(13, 1), Array(14, 1), Array(15, 1), Array(16, 1), _
        Array(17, 1), Array(18, 1), Array(19, 1), Array(20, 1), Array(21, 1), Array(22, 1), Array( _
        23, 1), Array(24, 1)), TrailingMinusNumbers:=True
   
    lr = Range("A" & Rows.Count).End(xlUp).Row
   
   
    Range("A1:X" & lr).Select
    Selection.Copy
    Windows(ThisWorkbook.Name).Activate
    Sheets(1).Range("A1").PasteSpecial Paste:=xlPasteValues
    Application.CutCopyMode = False
    Workbooks("AccountingDownload.xls").Close SaveChanges:=False
   
   
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,127,528
Messages
5,625,334
Members
416,096
Latest member
forevans

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top