Excel Macro Help, stopping popup error box?
-
Hello, I am trying to write a macro that automatically links data from another workbook based on the sheet name that is populated in column A. The problem is sometimes there is no sheet set, so when I run the macro a popup box comes up wanting me to select a sheet set. I would rather try to stop this box or not populate the cell at all. Sub Links() 'Running Macro Reply = MsgBox("This Macro will create Links" & Chr(10) & "Would you like to run this?", vbYesNo) If Reply = vbYes Then GoTo Line50 Else: GoTo Line700 Line50: 'Getting Link Properties Line100: Sheets("Test").Select Dim counter For counter = 3 To 5000 COUNTER2 = Range("A" & counter) JOBNUM = [COUNTER2] 'Making Links LINE200: If JOBNUM = "" Then GoTo LINE600 Line300: Range("M" & counter).Select ActiveCell = "=HYPERLINK(" & Chr(34) & "[Job Times.xlsx]'" & JOBNUM & "'!a1" & Chr(34) & ",SUM(N" & counter & ":Y" & counter & "))" Line350: Range("N" & counter).Select ActiveCell = "='F:\Production Tracking\[Job Times.xlsx]" & JOBNUM & "'!$F$5" On Error Resume Next ' ^---This is where I have problem of a popup box if the sheet doesn't exist Line400: Next counter LINE600: MsgBox "Auto Link Complete!" GoTo Line800 Line700: MsgBox "Auto Link Terminated" Line800: End Sub
-
Answer:
Application.DisplayAlerts = False On Error Resume Next ... Do your thing Application.DisplayAlerts = True On Error GoTo 0 ... Do whatever comes next
Zenkai at Yahoo! Answers Visit the source
Related Q & A:
- How to covert csv file to excel and back excel file to csv in python?Best solution by completecampaigns.com
- Can't delete name off messenger address list, error code 40402,need help pls?Best solution by Yahoo! Answers
- Myspace comment box help?
- How can I get help with my converter box problems?Best solution by Yahoo! Answers
- Sudden Link Cable Box help?Best solution by help.suddenlink.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.