1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Bug in VBA Excel 2007?

Discussion in 'Microsoft Office' started by Jo, Feb 11, 2010.

  1. Jo

    Jo Flightless Bird

    Hello,

    I'm trying to migrate a macro Excel 2003 to 2007 and I have the
    following problem:

    When running the code below, Err.Number is always 9 while in 2003
    Err.Number is 0:

    Public Sub Test ()
    Dim i As Long
    On Error Resume Next
    With ActiveSheet
    For i = 1 To 100
    . Cells (i, "A"). Value = i
    If Err.Number = 0 Then
    . Cells (i, "B"). Value = "OK"
    Else
    . Cells (i, "B"). Value = "KB (" & Err.Number & "-" &
    Err.Description & ")"
    End If
    Err.Clear
    Next
    End With
    End Sub

    Is this a BUG VBA 2007 or is it my code that Bugged (in this case why
    it works well in 2003?).

    Thank you for your help.
     
  2. macropod

    macropod Flightless Bird

    Hi Jo,

    In Excel 2007, I get Err 0 - all cells in column B have 'OK'. Is you copy of Excel fully patched?

    --
    Cheers
    macropod
    [Microsoft MVP - Word]


    "Jo" <j.tribaudini@gmail.com> wrote in message news:476c7d58-1314-4bf6-aa09-612f01daab2d@f8g2000yqn.googlegroups.com...
    > Hello,
    >
    > I'm trying to migrate a macro Excel 2003 to 2007 and I have the
    > following problem:
    >
    > When running the code below, Err.Number is always 9 while in 2003
    > Err.Number is 0:
    >
    > Public Sub Test ()
    > Dim i As Long
    > On Error Resume Next
    > With ActiveSheet
    > For i = 1 To 100
    > . Cells (i, "A"). Value = i
    > If Err.Number = 0 Then
    > . Cells (i, "B"). Value = "OK"
    > Else
    > . Cells (i, "B"). Value = "KB (" & Err.Number & "-" &
    > Err.Description & ")"
    > End If
    > Err.Clear
    > Next
    > End With
    > End Sub
    >
    > Is this a BUG VBA 2007 or is it my code that Bugged (in this case why
    > it works well in 2003?).
    >
    > Thank you for your help.
     
  3. Jo

    Jo Flightless Bird

    On 13 fév, 07:44, "macropod" <macro...@invalid.invalid> wrote:
    > Hi Jo,
    >
    > In Excel 2007, I get Err 0 - all cells in column B have 'OK'. Is you copyof Excel fully patched?
    >
    > --
    > Cheers
    > macropod
    > [Microsoft MVP - Word]
    >
    > "Jo" <j.tribaud...@gmail.com> wrote in messagenews:476c7d58-1314-4bf6-aa09-612f01daab2d@f8g2000yqn.googlegroups.com...
    > > Hello,

    >
    > > I'm trying to migrate a macro Excel 2003 to 2007 and I have the
    > > following problem:

    >
    > > When running  the code below, Err.Number is always 9 while in 2003
    > > Err.Number is 0:

    >
    > > Public Sub Test ()
    > >  Dim i As Long
    > >  On Error Resume Next
    > >  With ActiveSheet
    > >    For i = 1 To 100
    > >      . Cells (i, "A"). Value = i
    > >      If Err.Number = 0 Then
    > >        . Cells (i, "B"). Value = "OK"
    > >      Else
    > >        . Cells (i, "B"). Value = "KB (" & Err.Number & "-" &
    > > Err.Description & ")"
    > >      End If
    > >      Err.Clear
    > >    Next
    > >  End With
    > > End Sub

    >
    > > Is this a BUG VBA 2007 or is it my code that Bugged (in this case why
    > > it works well in 2003?).

    >
    > > Thank you for your help.


    Hi,

    Thank's for your answer.

    You can see on this link http://www.cijoint.fr/cjlink.php?file=cj201002/cij52nqbN0.pdf
    some informations about version and updates of my computer.

    Best regards
     
  4. macropod

    macropod Flightless Bird

    Hi Jo,

    I am unable to tell from that link whether your version is fully updated - the minor numbers are different than mine, but that may
    be because you are using: (a) a French-language installation; and (b) Office Standard (I have Office Professional - but the vba
    components should be the same)

    --
    Cheers
    macropod
    [Microsoft MVP - Word]


    "Jo" <j.tribaudini@gmail.com> wrote in message news:37bf954b-2370-4006-b07a-db04b49945be@q29g2000yqn.googlegroups.com...
    On 13 fév, 07:44, "macropod" <macro...@invalid.invalid> wrote:
    > Hi Jo,
    >
    > In Excel 2007, I get Err 0 - all cells in column B have 'OK'. Is you copy of Excel fully patched?
    >
    > --
    > Cheers
    > macropod
    > [Microsoft MVP - Word]
    >
    > "Jo" <j.tribaud...@gmail.com> wrote in messagenews:476c7d58-1314-4bf6-aa09-612f01daab2d@f8g2000yqn.googlegroups.com...
    > > Hello,

    >
    > > I'm trying to migrate a macro Excel 2003 to 2007 and I have the
    > > following problem:

    >
    > > When running the code below, Err.Number is always 9 while in 2003
    > > Err.Number is 0:

    >
    > > Public Sub Test ()
    > > Dim i As Long
    > > On Error Resume Next
    > > With ActiveSheet
    > > For i = 1 To 100
    > > . Cells (i, "A"). Value = i
    > > If Err.Number = 0 Then
    > > . Cells (i, "B"). Value = "OK"
    > > Else
    > > . Cells (i, "B"). Value = "KB (" & Err.Number & "-" &
    > > Err.Description & ")"
    > > End If
    > > Err.Clear
    > > Next
    > > End With
    > > End Sub

    >
    > > Is this a BUG VBA 2007 or is it my code that Bugged (in this case why
    > > it works well in 2003?).

    >
    > > Thank you for your help.


    Hi,

    Thank's for your answer.

    You can see on this link http://www.cijoint.fr/cjlink.php?file=cj201002/cij52nqbN0.pdf
    some informations about version and updates of my computer.

    Best regards
     

Share This Page