Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
when i try to run the program it shows the run time error.

What I have tried:

VB
Sub Macro1()
For i = 1 To 255
Worksheets("sheet1").Select
Worksheets("sheet1").Activate
mystr = "http://www.medifee.com/dc/243-rushabh-diagnostic-centre/"
mystr = Cells(i, 1)
Worksheets.Add(After:=Worksheets(Worksheet.Count)).Name = i
ActiveWorkbook.Worksheets.Add
    With ActiveSheet.QueryTables.Add(Connection:= _
        mystr, Destination:= _
        Range("$A$1"))
        .Name = "243-rushabh-diagnostic-center"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .WebSelectionType = xlAllTables
        .WebFormatting = xlWebFormattingNone
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        .Refresh BackgroundQuery:=False
    End With



Next
End Sub
Posted
Updated 11-Feb-19 0:28am
v2

We can't tell - we don't have access to your data to check the code and work it out for you.
So, its going to be up to you.
Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.

Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!

Have a look at these, they may help you get started:
MS Excel 2013: VBA Debugging Introduction[^]
Ways to Step Through Code in VBA[^]
 
Share this answer
 
Use the debgger and execute your macro line by line and inspect variables for changes after each line.
VB
mystr = "http://www.medifee.com/dc/243-rushabh-diagnostic-centre/"
mystr = Cells(i, 1)

The second line kills the first one.
Check that the QueryTables do not fail because of it.
 
Share this answer
 
Option Explicit

Dim NextBlink As String
Dim blinkingcells As Range
Sub StartBlink()
    If blinkingcells Is Nothing Then
    Set blinkingcells = Selection
    Call Blinking
    Else
    Set blinkingcells = Union(blinkingcells, Selection)
    End If
End Sub
Sub Blinking()
    Dim cell As Range
    For Each cell In blinkingcells
        If cell.Interior.ColorIndex = 4 Then
            cell.Interior.ColorIndex = 0
        Else
        cell.Interior.ColorIndex = 4
        End If
    Next
    NextBlink = Now + TimeSerial(0, 0, 0.6)
    Application.OnTime NextBlink, "Blinking", True
End Sub
 
Share this answer
 
Comments
Richard Deeming 12-Feb-19 11:05am    
Absolutely nothing to do with the question!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900