Error 400 weird problem please help

ShadesUK

New Member
Joined
Feb 22, 2016
Messages
6
Hi,

I have a problem that is really starting to drive me crazy as I have not been able to figure it out.

Firstly, our setup:

We have 3 computers

Computer 1
Windows 7 4GB Ram
Office 2010

Computer 2
Windows 7 4GB Ram
Office 2013

Computer 3
Windows 7 4GB Ram
Office 2013


The Problem
We have a spreadsheet that I have created with extensive VBA coding in it essentially what the spreadheet does is once a date has been entered into a specific cell and the user clicks on a button the VBA code refreshes an ODBC link to Sage and pulls through all the data from Sage's main database then goes through multiple sheets updating pivot tables which sort all of the raw data and feeds through to the main sheets which are the only ones the user sees. Then it does the same thing again for another ODBC link. The spreadsheet was created a few years ago for a different office, about 1 year ago I modified it to meet the current needs on the current office setup. Computer 1 is the computer I did all of the modifications and testing. The spreadsheet works perfectly on Computer 1 and Computer 2 and worked without fault in the old office system. Computer 3 is the one that has the problems running the spreadsheet the majority of the time when running the VBA code in the spreadsheet on computer 3 it will fall over part way through returning an error 400, however sometimes when opening and running the file it will just work. I have checked memory issues by doing a check on the memory which came back as no faults and by swapping the memory form Computer 2 and Computer 3 which did not resolve the issue. I have also tried ending processes running in the background to check for any conflicts, in some cases if I have the problem then end all of the unecesary processes, re-open the spreadsheet and try again it will work however, I restarted the machine and attempted to confirm it was one of those processes causing a conflict by running the spreadsheet to get the error(which it did) then ended the same processes again, but this time it did not fix the error problem. So the problem is intermitant on one computer only, i have been trying to figure this out for months and am at a loss. I would greatly appreciate any help.

The Main body of the code is below, however I do not believe the code is the problem as it works without error everytime on all other computers that it has been run on.
Code:
Sub RefreshRep()
    Application.ScreenUpdating = False
    Sheets("RAW DATA").Visible = True
    Sheets("RAW DATA").Select
    Sheets("RAW DATA").Range("A1").Select
    Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
    Call AftRef
    Sheets("RAW DATA").Visible = False
    Sheets("LedEnd").Visible = True
    Sheets("LedEnd").Select
    Sheets("LedEnd").Range("A1").Select
    Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
    Call AftRef2
    Sheets("LedEnd").Visible = False
    Sheets("Control Sheet").Select

    Sheets("period").Visible = True
    Sheets("period").Select
    Range("H2").Value = "=COUNTIF('RAW DATA'!B:B,""TRUE"")"
        If Range("H2").Value > 0 Then
            Range("B1").Value = "True"
        Else
            Range("B1").Value = "(blank)"
        End If
    ActiveSheet.PivotTables("PivotTable2").PivotCache.Refresh
    Sheets("period").Visible = False
    
    Sheets("Pperiod").Visible = True
    Sheets("Pperiod").Select
    Range("H2").Value = "=COUNTIF('RAW DATA'!D:D,""TRUE"")"
        If Range("H2").Value > 0 Then
            Range("B1").Value = "True"
        Else
            Range("B1").Value = "(blank)"
        End If
    ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
    Sheets("Pperiod").Visible = False
    
    Sheets("YTD").Visible = True
    Sheets("YTD").Select
    Range("H2").Value = "=COUNTIF('RAW DATA'!C:C,""TRUE"")"
        If Range("H2").Value > 0 Then
            Range("B1").Value = "True"
        Else
            Range("B1").Value = "(blank)"
        End If
    ActiveSheet.PivotTables("PivotTable8").PivotCache.Refresh
    Sheets("YTD").Visible = False
    
    Sheets("PYTD").Visible = True
    Sheets("PYTD").Select
    Range("H2").Value = "=COUNTIF('RAW DATA'!E:E,""TRUE"")"
        If Range("H2").Value > 0 Then
            Range("B1").Value = "True"
        Else
            Range("B1").Value = "(blank)"
        End If
    ActiveSheet.PivotTables("PivotTable9").PivotCache.Refresh
    Sheets("PYTD").Visible = False
    
    Sheets("CUMU").Visible = True
    Sheets("CUMU").Select
    Range("H2").Value = "=COUNTIF('RAW DATA'!P:P,""TRUE"")"
        If Range("H2").Value > 0 Then
            Range("B1").Value = "True"
        Else
            Range("B1").Value = "(blank)"
        End If
    ActiveSheet.PivotTables("PivotTable10").PivotCache.Refresh
    Sheets("CUMU").Visible = False
    
    Sheets("PCUMU").Visible = True
    Sheets("PCUMU").Select
    ActiveSheet.PivotTables("PivotTable12").PivotCache.Refresh
    Sheets("PCUMU").Visible = False
        
    Sheets("AllCurr").Visible = True
    Sheets("AllCurr").Select
    ActiveSheet.PivotTables("PivotTable5").PivotCache.Refresh
    ActiveSheet.PivotTables("PivotTable6").PivotCache.Refresh
    Sheets("AllCurr").Visible = False
    
    Sheets("AllPrior").Visible = True
    Sheets("AllPrior").Select
    ActiveSheet.PivotTables("PivotTable2").PivotCache.Refresh
    ActiveSheet.PivotTables("PivotTable7").PivotCache.Refresh
    Sheets("AllPrior").Visible = False
        
    Sheets("Control Sheet").Select
    Range("A7").Select
    Application.ScreenUpdating = True

End Sub
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Forum statistics

Threads
1,216,100
Messages
6,128,834
Members
449,471
Latest member
lachbee

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