Results 1 to 5 of 5

Method `Range of object_'Worksheet' failed - Trying to write variable to cell

Threaded View

  1. #1
    Registered User
    Join Date
    11-13-2013
    Location
    Aberdeenshire, Scotland
    MS-Off Ver
    Excel 2010
    Posts
    3

    Method `Range of object_'Worksheet' failed - Trying to write variable to cell

    Hi All - Hoping someone can assist.

    I am trying to update a spreadsheet I have used for carrying out a wall thickness calculation on piping, and thought it would be a great idea to try and learn VBA at the same time. I have managed to put together some code that generally does what I need (basically finding values in a table of data and interpolating to get intermediate figures) but I am getting an error trying to write the result to a cell.

    Error:
    Run-time error '-2147417848 (80010108)':
    Method `Range of object_'Worksheet' failed

    I then get `Not Enough System Resources to Display Completely'

    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)
    
    'Define General Variables
        
        Dim SIZE
        Dim CLASS
        Dim MATERIAL
        Dim PIPETYPE
        Dim GROUP
        Dim SCH
        Dim PRES_D
        Dim TEMP_DU
        
        Dim TEMP_DL
        Dim MATFAM
        Dim GROUP_PT
    
    'Define Pressure/Temperature Calculation Variables
    
        Dim TEMP_PTL
        Dim TEMP_PTU
        Dim PRES_PTL
        Dim PRES_PTU
        Dim PRES_PTDIFF
        Dim TEMP_PTDIFF
        Dim RATIO_PT
        Dim TEMP_INC 'Temperature Increase above TEMP_PTL
            
    'Define Coordinate Calculation Variables
    
        Dim ROW_S
        Dim COL_S1
        Dim COL_S2
        Dim ROW_PT
        Dim COL_PT1
        Dim COL_PT2
    
    '   Set-up Known Variables
        
        CLASS = Worksheets("ASME B31.3 CALCULATION").Cells(4, "D").Value
        GROUP = Worksheets("ASME B31.3 CALCULATION").Cells(14, "D").Value
        GROUP_PT = GROUP & " - " & CLASS
        
    With Application.WorksheetFunction
    
        ROW_PT = .Match(GROUP_PT, Worksheets("ASME B16.5 TABLES").Range("C3:C142"), 0) 'Determine Row Number for Group
        COL_PT1 = .Match(TEMP_DU, Worksheets("ASME B16.5 TABLES").Range("D2:AF2"), 1) ' Determine Column Number for Lower Temperature
        COL_PT2 = COL_PT1 + 1 ' Determine Column Number for Upper Temperature
    
        TEMP_PTL = .Index(Worksheets("ASME B16.5 TABLES").Range("D2:AF2"), 1, COL_PT1, 1) ' Determine Lower Temperature Value
        TEMP_PTU = .Index(Worksheets("ASME B16.5 TABLES").Range("D2:AF2"), 1, COL_PT1 + 1, 1) ' Determine Lower Temperature Value
    
        PRES_PTU = .Index(Worksheets("ASME B16.5 TABLES").Range("D3:AF142"), ROW_PT, COL_PT1) 'Determine Lower Pressure Value
        PRES_PTL = .Index(Worksheets("ASME B16.5 TABLES").Range("D3:AF142"), ROW_PT, COL_PT2) ' Determine Upper Pressure Value
    
    End With
    
        PRES_PTDIFF = PRES_PTU - PRES_PTL 'Determine Pressure Differential
        TEMP_PTDIFF = TEMP_PTU - TEMP_PTL 'Determine Temperature Differential
    
        RATIO_PT = PRES_PTDIFF / TEMP_PTDIFF 'Increase in Pressure Per Deg C
    
        TEMP_INC = TEMP_DU - TEMP_PTL
        
        Sheets("ASME B31.3 CALCULATION").Range("M16") = (PRES_PTU - (RATIO_PT * TEMP_INC))
            
       
    End Sub
    Any help/pointer would be very much appreciated :-)

    Thanks

    Steve
    Last edited by stevemcd1; 12-17-2013 at 04:00 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Using If Statement to format a bookmark (complete newbie)
    By kiwigal in forum Word Programming / VBA / Macros
    Replies: 1
    Last Post: 01-30-2013, 06:41 AM
  2. A complete newbie - please help with a password problem
    By alexisemma31 in forum Excel General
    Replies: 9
    Last Post: 08-02-2012, 02:36 AM
  3. Replies: 4
    Last Post: 06-13-2012, 01:34 AM
  4. complete macro newbie
    By savfam02 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-25-2010, 09:14 PM
  5. If then:complete newbie
    By Cydney in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-27-2009, 01:31 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1