LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default VB scripts from Office 97 that no longer work in Office 2003

Hi!

Some years ago, I wrote two VB scripts for Excel in Office 97. Today, I
discovered that they no longer work with Excel in Office 2003. Both failures
seem to be related to "Cells". Could somebody please help me with how to
rewrite the scripts to get rid of the errors?

In the first script, I get "Run-time error '1004': Application-defined or
object-defined error" for the line "Cells(Row, Column) = 0" in the following
script. Does anybody know why I get this error and how to rewrite the code
to get rid of it. Unfortunately, I don't remember much about writing Visual
Basic scripts. I just did it briefly and it was some years ago.

'
' Diagramdata Makro
'
' Detta makro fyller i de två diagrammen över basaldos i ett testprotokoll
efter värdena i
' tabellerna längst upp till vänster på de två sidorna som testprotokollet
utgörs av.
'
' Kortkommando: Ctrl+d
'
Sub Diagramdata()
Dim Row As Integer, Column As Integer
Dim Intervall As String
Dim FrånTid As Integer, TillTid As Integer
Dim Time As Integer
Dim i As Integer

Row = 6
For Column = 38 To 61
Cells(Row, Column) = 0
Next Column

Row = 53
For Column = 38 To 61
Cells(Row, Column) = 0
Next Column

For i = 0 To 1
Row = 5 + (47 * i)
Intervall = Cells(Row, 1)
Do While (Row < 15 + (47 * i) And Intervall < "")
Intervall = Cells(Row, 1)
FrånTid = Val(Left(Intervall, 2))
TillTid = Val(Right(Intervall, 2))
If TillTid FrånTid Then
For Time = FrånTid To TillTid - 1
Cells(6 + (47 * i), 38 + Time) = Cells(Row, 2)
Next Time
Else
For Time = FrånTid To 23
Cells(6 + (47 * i), 38 + Time) = Cells(Row, 2)
Next Time
For Time = 0 To TillTid - 1
Cells(6 + (47 * i), 38 + Time) = Cells(Row, 2)
Next Time
End If
Row = Row + 1
Intervall = Cells(Row, 1)
Loop
Next i

End Sub

In the second script, I get "Run-time error '-2147319784 (80028018)':
Automation error Invalid data format" for the line "If Cells(Row, Column) =
"Neg" Then". The macro is listed below. Does anybody know how I can modify
the script to get it working?

'
' Textfärg Makro
'
' Detta makro går igenom ett testprotokoll och ändrar färgerna på texten för
' urin- och blodsockervärden beroende på hur högt värdet är.
'
' Kortkommando: Ctrl+t
'

Sub Textfärg()
Dim i As Integer, Row As Integer, Column As Integer
Dim Blodsockervärde As Double

For i = 0 To 1
For Row = (20 + 47 * i) To (50 + 47 * i) Step 2
For Column = 2 To 4
If Cells(Row, Column) = "Neg" Then
Cells(Row, Column).Font.ColorIndex = 10
ElseIf Left(Cells(Row, Column), 1) < "-" And Cells(Row, Column) <
"?" And Cells(Row, Column) < "" Then
Cells(Row, Column).Font.ColorIndex = 3
Else
Cells(Row, Column).Font.ColorIndex = 0
End If
Next Column
For Column = 5 To 13
If Left(Cells(Row, Column), 1) = "-" Then
Cells(Row, Column).Font.ColorIndex = 0
Else
If Left(Cells(Row, Column), 2) < "ca" Then
Blodsockervärde = CDbl(Cells(Row, Column))
Else
Blodsockervärde = CDbl(Right(Cells(Row, Column), Len(Cells(Row,
Column)) - 2))
End If
If Blodsockervärde <= 4.5 And Blodsockervärde 0 Then
Cells(Row, Column).Font.ColorIndex = 5
ElseIf Blodsockervärde = 8.5 Then
Cells(Row, Column).Font.ColorIndex = 3
ElseIf Blodsockervärde 4.5 And Blodsockervärde < 8.5 Then
Cells(Row, Column).Font.ColorIndex = 10
Else
Cells(Row, Column).Font.ColorIndex = 0
End If
End If
Next Column
Next Row
Next i
End Sub

Best Regards,

Christian Johansson (change "combort" to "comhem" in my e-mail address if
responding via e-mail)


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to work with files copied from Office 2004 (MAC) in Office rgranell Excel Worksheet Functions 3 June 19th 08 04:31 PM
Office 2007 compatibility pack on Office 2003 (slow network file fox_mulder33 Setting up and Configuration of Excel 0 January 2nd 08 03:28 PM
Office 2000/Office 2003 Excel not printing landscape vise versa BAHTTEXT in English text Setting up and Configuration of Excel 1 April 17th 06 01:37 PM
VBA does not work for Office 2003 Pat Excel Discussion (Misc queries) 3 November 22nd 05 08:00 PM
Office 2003 - "autocomplete" in file | open or file | save no longer works Lanwench [MVP - Exchange] Excel Discussion (Misc queries) 4 January 12th 05 01:35 AM


All times are GMT +1. The time now is 06:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"