![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: May 2002
Posts: 1
|
Briefly I will tell you the problem in case you can help or know someone who could. The problem is I have an Excel sheet with a macro wrote in it. When I run the program from Excel office 2000 it works fine. If I run it from my office 97 at work it gives me this error "Instruction at "0x003a0043" referenced memory at "0x003a0043". The memory could not be read." then kick me out of Excel completely! Any info would be great...
below is the VB code: Sub Macro11() ' ' Macro11 Macro ' Macro 2/1/01 by mccormp ActiveSheet.Unprotect ("ptm") Range("J44") = 0 Range("F35") = 100 Range("J45") = 100 Line1: If Range("F44") <= 0 Then GoTo Line2 ElseIf Range("F35") - Range("F41") > 0 Then Range("F35") = Range("J44") Range("J45") = Range("J45") * 0.1 Range("j44") = Range("F35") Range("F35") = Range("F35") + Range("J45") Else Range("J44") = Range("F35") Range("F35") = Range("F35") + Range("J45") End If GoTo Line1 Line2: Range("F45") = 0.5 - Range("F38") / (2 * Range("D8")) * (1 - 2 * Range("D7")) ActiveSheet.Protect ("ptm") End Sub Thanks for the HELP!! Patrick McCormack Mechanical Engineer TRW Aeronautical Systems, Utica, NY phone: (315) 838-1281 fax: (315) 838-1273 fax email: pat.mccormack@trw.com |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
|
I don't see anything off hand that would be causing Excel to crash. Possibly try to copy your code, delete the module, insert a new module and then paste the code.
Also, the GoTo lines might be doing something weird, although I don't see what could be occurring. Here is your code rewritten without the GoTo lines. Possibly it may work for you. Code:
Sub test()
With ActiveSheet
.Unprotect ("ptm")
.Range("J44") = 0
.Range("F35,J45") = 100
Do Until .Range("F44") <= 0
If .Range("F35") - .Range("F41") > 0 Then
.Range("F35") = .Range("J44")
.Range("J45") = .Range("J45") / 10
.Range("j44") = .Range("F35")
.Range("F35") = .Range("F35") + .Range("J45")
Else
.Range("J44") = .Range("F35")
.Range("F35") = .Range("F35") + .Range("J45")
End If
Loop
.Range("F45") = 0.5 - .Range("F38") / _
(2 * .Range("D8")) * (1 - 2 * .Range("D7"))
.Protect ("ptm")
End With
End Sub
Jay |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
Hi
If Jay's instructions don't help, then try this as well. Append .Value to all of your Ranges Change: Range("F35") to: Range("F35").Value Tom |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|