I have a strange problem....
When I run a macro on my mac or on my work PC, it works perfectly well. However, when the guy who I wrote the macro for, runs it on his PC, excel closes with an error (in french so the translation may not be perfect) saying insufficient battery. I have no idea why..
This is my macro
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCellCaps As Range
Dim KeyCellNom As Range
Dim KeyCellMedia As Range
Dim KeyCellPrenom As Range
Dim KeyCellVille As Range
Dim KeyCellPostale As Range
Dim KeyCellTel As Range
Dim KeyCellFax As Range
Set KeyCellCaps = Range("A:A")
Set KeyCellNom = Range("A:A")
Set KeyCellPrenom = Range("B:B")
Set KeyCellMedia = Range("C:C")
Set KeyCellPostale = Range("E:E")
Set KeyCellVille = Range("F:F")
Set KeyCellTel = Range("G:G")
Set KeyCellFax = Range("H:H")
Column = "Q"
' Mettre le nom en majuscule et rajouter la date d'ajout
If Not Application.Intersect(KeyCellCaps, Range(Target.Address)) _
Is Nothing Then
If Target.Count > 1 Then Exit Sub
Target.Value = UCase(Target.Text)
Intcolumn = Target.Column
introw = Target.Row
Cells(introw, Column) = Now()
End If
' si le prénom est rajouté ou modifié, rajouter la date d'ajout
If Not Application.Intersect(KeyCellPrenom, Range(Target.Address)) _
Is Nothing Then
Prenom = Target.Text
P = Left(Prenom, 1)
P = UCase(P)
Renom = Mid(Prenom, 2)
Prenom = P & Renom
Target.Value = Prenom
Intcolumn = Target.Column
introw = Target.Row
Cells(introw, Column) = Now()
End If
' si le champ Médias est rajouté ou modifié, rajouter la date d'ajout
If Not Application.Intersect(KeyCellMedia, Range(Target.Address)) _
Is Nothing Then
Intcolumn = Target.Column
introw = Target.Row
Cells(introw, Column) = Now()
End If
'Convertir le code postale
If Not Application.Intersect(KeyCellPostale, Range(Target.Address)) _
Is Nothing Then
v = [{"&",1;"é",2;"""",3;"'",4;"(",5;"§",6;"è",7;"!",8;"ç",9;"à",0}]
s = Target.Value
For j = 1 To 10
s = Replace(s, v(j, 1), v(j, 2))
Next j
Application.EnableEvents = False
Range(Target.Address) = s
Application.EnableEvents = True
End If
'Convertir le numéro de téléphone
If Not Application.Intersect(KeyCellTel, Range(Target.Address)) _
Is Nothing Then
v = [{"&",1;"é",2;"""",3;"'",4;"(",5;"§",6;"è",7;"!",8;"ç",9;"à",0}]
s = Target.Value
For j = 1 To 10
s = Replace(s, v(j, 1), v(j, 2))
Next j
Application.EnableEvents = False
Range(Target.Address) = s
Application.EnableEvents = True
End If
'Convertir le numéro de fax
If Not Application.Intersect(KeyCellFax, Range(Target.Address)) _
Is Nothing Then
v = [{"&",1;"é",2;"""",3;"'",4;"(",5;"§",6;"è",7;"!",8;"ç",9;"à",0}]
s = Target.Value
For j = 1 To 10
s = Replace(s, v(j, 1), v(j, 2))
Next j
Application.EnableEvents = False
Range(Target.Address) = s
Application.EnableEvents = True
End If
' Mettre le nom de la ville en majuscules
If Not Application.Intersect(KeyCellVille, Range(Target.Address)) _
Is Nothing Then
Target.Value = UCase(Target.Text)
End If
End Sub
Anyone have any ideas? (does it work for you?)
Basically what it does is this:
Rows A & F - Convert the text to UpperCase
Row B - Convert the text to ProperCase
Rows E,G & H - Converts numbers entered on a french keyboard without the shift key having being pressed into numbers.
Thanks
Steph
PS, the error says:
Erreur d'exécution
Espace Pile insuffisant
(pile is actually battery but I'm guessing it means insufficient disk space)
When I run a macro on my mac or on my work PC, it works perfectly well. However, when the guy who I wrote the macro for, runs it on his PC, excel closes with an error (in french so the translation may not be perfect) saying insufficient battery. I have no idea why..
This is my macro
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCellCaps As Range
Dim KeyCellNom As Range
Dim KeyCellMedia As Range
Dim KeyCellPrenom As Range
Dim KeyCellVille As Range
Dim KeyCellPostale As Range
Dim KeyCellTel As Range
Dim KeyCellFax As Range
Set KeyCellCaps = Range("A:A")
Set KeyCellNom = Range("A:A")
Set KeyCellPrenom = Range("B:B")
Set KeyCellMedia = Range("C:C")
Set KeyCellPostale = Range("E:E")
Set KeyCellVille = Range("F:F")
Set KeyCellTel = Range("G:G")
Set KeyCellFax = Range("H:H")
Column = "Q"
' Mettre le nom en majuscule et rajouter la date d'ajout
If Not Application.Intersect(KeyCellCaps, Range(Target.Address)) _
Is Nothing Then
If Target.Count > 1 Then Exit Sub
Target.Value = UCase(Target.Text)
Intcolumn = Target.Column
introw = Target.Row
Cells(introw, Column) = Now()
End If
' si le prénom est rajouté ou modifié, rajouter la date d'ajout
If Not Application.Intersect(KeyCellPrenom, Range(Target.Address)) _
Is Nothing Then
Prenom = Target.Text
P = Left(Prenom, 1)
P = UCase(P)
Renom = Mid(Prenom, 2)
Prenom = P & Renom
Target.Value = Prenom
Intcolumn = Target.Column
introw = Target.Row
Cells(introw, Column) = Now()
End If
' si le champ Médias est rajouté ou modifié, rajouter la date d'ajout
If Not Application.Intersect(KeyCellMedia, Range(Target.Address)) _
Is Nothing Then
Intcolumn = Target.Column
introw = Target.Row
Cells(introw, Column) = Now()
End If
'Convertir le code postale
If Not Application.Intersect(KeyCellPostale, Range(Target.Address)) _
Is Nothing Then
v = [{"&",1;"é",2;"""",3;"'",4;"(",5;"§",6;"è",7;"!",8;"ç",9;"à",0}]
s = Target.Value
For j = 1 To 10
s = Replace(s, v(j, 1), v(j, 2))
Next j
Application.EnableEvents = False
Range(Target.Address) = s
Application.EnableEvents = True
End If
'Convertir le numéro de téléphone
If Not Application.Intersect(KeyCellTel, Range(Target.Address)) _
Is Nothing Then
v = [{"&",1;"é",2;"""",3;"'",4;"(",5;"§",6;"è",7;"!",8;"ç",9;"à",0}]
s = Target.Value
For j = 1 To 10
s = Replace(s, v(j, 1), v(j, 2))
Next j
Application.EnableEvents = False
Range(Target.Address) = s
Application.EnableEvents = True
End If
'Convertir le numéro de fax
If Not Application.Intersect(KeyCellFax, Range(Target.Address)) _
Is Nothing Then
v = [{"&",1;"é",2;"""",3;"'",4;"(",5;"§",6;"è",7;"!",8;"ç",9;"à",0}]
s = Target.Value
For j = 1 To 10
s = Replace(s, v(j, 1), v(j, 2))
Next j
Application.EnableEvents = False
Range(Target.Address) = s
Application.EnableEvents = True
End If
' Mettre le nom de la ville en majuscules
If Not Application.Intersect(KeyCellVille, Range(Target.Address)) _
Is Nothing Then
Target.Value = UCase(Target.Text)
End If
End Sub
Anyone have any ideas? (does it work for you?)
Basically what it does is this:
Rows A & F - Convert the text to UpperCase
Row B - Convert the text to ProperCase
Rows E,G & H - Converts numbers entered on a french keyboard without the shift key having being pressed into numbers.
Thanks
Steph
PS, the error says:
Erreur d'exécution
Espace Pile insuffisant
(pile is actually battery but I'm guessing it means insufficient disk space)