VBA auto click ok on pop up box

davidcoad

New Member
Joined
May 25, 2007
Messages
16
Hi,

I have a file that contains all of our products in a .csv format and is updated every night. So I can import it into our local reporting software I need to convert it to an excel document with variables in their own column as opposed to being all in one column and seperated by "|" (as per the .csv), and then save as an excel spreadsheet .xls.

I am writing a macro to open the .csv file, select column A and then select "Text to Columns" to move the data deliminated by a "|" into individual columns.

when I do this I get a pop up box that asks "do you want to replace the contents of the destination cells" which requires me to hit OK.

I want to automate this whole process so it happens everyday based on a a schedule so I never have to manually update the file when new products are added (which is regularly).

The part that I cannot do is making the macro auto select OK when the dialogue box pops up.

The code for the text to columns is:

Columns("A:A").Select
Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:="|", 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)), TrailingMinusNumbers:=True

Anyone know how to select OK in the pop up box in VBA?

Thanks
Dave
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
You can use Application.DisplayAlerts = False at the beginning of you code. Just make sure to set it back to True at the end.

And note that it's rarely necessary to select objects in order to work with them, so generally when you see "Select" followed by "Selection" you can eliminate both statements:

Code:
Columns("A:A").TextToColumns...

HTH,
 
Upvote 0

Forum statistics

Threads
1,221,925
Messages
6,162,871
Members
451,799
Latest member
yrga88

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
Back
Top