OVH Cloud OVH Cloud

Else if problem

9 réponses
Avatar
mboileau
Hi, I have problem with this macro. It tells me " Else sans If" at
this line "Else: If Month(Now()) = 12 Then ThisWorkbook.SaveCopyAs
NomFich2". Whats'wrong?


NomFich = "G:\Banques\Banque " & Format(Now(), "yyyy") & "\" &
Format(Now(), "dd-mmm-yy") & ".xls"
NomFich2 = "G:\Banques\Banque " & Format(Now() + 200, "yyyy") &
"\" & Format(Now(), "dd-mmm-yy") & ".xls"
For Each Feuil In ThisWorkbook.Worksheets
Feuil.UsedRange.Copy
Feuil.UsedRange.PasteSpecial xlPasteValues
Application.CutCopyMode = False
Next Feuil

If Month(Now()) = 11 Then ThisWorkbook.SaveCopyAs NomFich2
If Month(Now()) = 12 Then ThisWorkbook.SaveCopyAs
NomFich2
Else: ThisWorkbook.SaveCopyAs NomFich
End If
End If
ThisWorkbook.Saved = True

Thanks mp

9 réponses

Avatar
mboileau

Sorry the problem is at this line "Else: ThisWorkbook.SaveCopyAs NomFich" . Whats'wrong?


NomFich = "G:BanquesBanque " & Format(Now(), "yyyy") & "" &
Format(Now(), "dd-mmm-yy") & ".xls"
NomFich2 = "G:BanquesBanque " & Format(Now() + 200, "yyyy") &
"" & Format(Now(), "dd-mmm-yy") & ".xls"
For Each Feuil In ThisWorkbook.Worksheets
Feuil.UsedRange.Copy
Feuil.UsedRange.PasteSpecial xlPasteValues
Application.CutCopyMode = False
Next Feuil

If Month(Now()) = 11 Then ThisWorkbook.SaveCopyAs NomFich2
If Month(Now()) = 12 Then ThisWorkbook.SaveCopyAs
NomFich2
Else: ThisWorkbook.SaveCopyAs NomFich
End If
End If
ThisWorkbook.Saved = True

Thanks mp


Avatar
JB
Perhaps?

If Month(Now()) = 11 Then
ThisWorkbook.SaveCopyAs NomFich2
If Month(Now()) = 12 Then
ThisWorkbook.SaveCopyAs NomFich2
Else: ThisWorkbook.SaveCopyAs NomFich
End If
End If

Cordialy JB


Hi, I have problem with this macro. It tells me " Else sans If" at
this line "Else: If Month(Now()) = 12 Then ThisWorkbook.SaveCopyAs
NomFich2". Whats'wrong?


NomFich = "G:BanquesBanque " & Format(Now(), "yyyy") & "" &
Format(Now(), "dd-mmm-yy") & ".xls"
NomFich2 = "G:BanquesBanque " & Format(Now() + 200, "yyyy") &
"" & Format(Now(), "dd-mmm-yy") & ".xls"
For Each Feuil In ThisWorkbook.Worksheets
Feuil.UsedRange.Copy
Feuil.UsedRange.PasteSpecial xlPasteValues
Application.CutCopyMode = False
Next Feuil

If Month(Now()) = 11 Then ThisWorkbook.SaveCopyAs NomFich2
If Month(Now()) = 12 Then ThisWorkbook.SaveCopyAs
NomFich2
Else: ThisWorkbook.SaveCopyAs NomFich
End If
End If
ThisWorkbook.Saved = True

Thanks mp


Avatar
isabelle
bonjour mp,

If Month(Now()) = 11 Then ThisWorkbook.SaveCopyAs NomFich2
If Month(Now()) = 12 Then
ThisWorkbook.SaveCopyAs NomFich2
Else:
ThisWorkbook.SaveCopyAs NomFich
End If


isabelle

Hi, I have problem with this macro. It tells me " Else sans If" at
this line "Else: If Month(Now()) = 12 Then ThisWorkbook.SaveCopyAs
NomFich2". Whats'wrong?


NomFich = "G:BanquesBanque " & Format(Now(), "yyyy") & "" &
Format(Now(), "dd-mmm-yy") & ".xls"
NomFich2 = "G:BanquesBanque " & Format(Now() + 200, "yyyy") &
"" & Format(Now(), "dd-mmm-yy") & ".xls"
For Each Feuil In ThisWorkbook.Worksheets
Feuil.UsedRange.Copy
Feuil.UsedRange.PasteSpecial xlPasteValues
Application.CutCopyMode = False
Next Feuil

If Month(Now()) = 11 Then ThisWorkbook.SaveCopyAs NomFich2
If Month(Now()) = 12 Then ThisWorkbook.SaveCopyAs
NomFich2
Else: ThisWorkbook.SaveCopyAs NomFich
End If
End If
ThisWorkbook.Saved = True

Thanks mp



Avatar
Jacquouille
Allo Jeanne?

--
Bien amicalmement,
Vivement conseillés:
http://www.excelabo.net
http://jacxl.free.fr/mpfe/trombino.html
http://dj.joss.free.fr/netiquet.htm
http://frederic.sigonneau.free.fr/

Jacquouille.

a écrit dans le message de news:

Hi, I have problem with this macro. It tells me " Else sans If" at
this line "Else: If Month(Now()) = 12 Then ThisWorkbook.SaveCopyAs
NomFich2". Whats'wrong?


NomFich = "G:BanquesBanque " & Format(Now(), "yyyy") & "" &
Format(Now(), "dd-mmm-yy") & ".xls"
NomFich2 = "G:BanquesBanque " & Format(Now() + 200, "yyyy") &
"" & Format(Now(), "dd-mmm-yy") & ".xls"
For Each Feuil In ThisWorkbook.Worksheets
Feuil.UsedRange.Copy
Feuil.UsedRange.PasteSpecial xlPasteValues
Application.CutCopyMode = False
Next Feuil

If Month(Now()) = 11 Then ThisWorkbook.SaveCopyAs NomFich2
If Month(Now()) = 12 Then ThisWorkbook.SaveCopyAs
NomFich2
Else: ThisWorkbook.SaveCopyAs NomFich
End If
End If
ThisWorkbook.Saved = True

Thanks mp



Avatar
lSteph
;o)))

Non Jacquouille ( Jane!!!)
--
lSteph

(..et après cela Jean-Paul, dira encore que j'suis Au pack)

"Jacquouille" a écrit dans le message de
news:
Allo Jeanne?

--
Bien amicalmement,
Vivement conseillés:
http://www.excelabo.net
http://jacxl.free.fr/mpfe/trombino.html
http://dj.joss.free.fr/netiquet.htm
http://frederic.sigonneau.free.fr/

Jacquouille.

a écrit dans le message de news:

Hi, I have problem with this macro. It tells me " Else sans If" at
this line "Else: If Month(Now()) = 12 Then ThisWorkbook.SaveCopyAs
NomFich2". Whats'wrong?


NomFich = "G:BanquesBanque " & Format(Now(), "yyyy") & "" &
Format(Now(), "dd-mmm-yy") & ".xls"
NomFich2 = "G:BanquesBanque " & Format(Now() + 200, "yyyy") &
"" & Format(Now(), "dd-mmm-yy") & ".xls"
For Each Feuil In ThisWorkbook.Worksheets
Feuil.UsedRange.Copy
Feuil.UsedRange.PasteSpecial xlPasteValues
Application.CutCopyMode = False
Next Feuil

If Month(Now()) = 11 Then ThisWorkbook.SaveCopyAs NomFich2
If Month(Now()) = 12 Then ThisWorkbook.SaveCopyAs
NomFich2
Else: ThisWorkbook.SaveCopyAs NomFich
End If
End If
ThisWorkbook.Saved = True

Thanks mp







Avatar
jps
heu....non pas, non pas, stéphane : je pense que notre liègeois (qui
bravissimus est) veut parler de Jehanne, la bonne Lorraine qu'Anglois
bruslèrent à Rouen
jps (innocent comme une nonne aux pâques)


"lSteph" a écrit dans le message de news:
%
;o)))

Non Jacquouille ( Jane!!!)
--
lSteph

(..et après cela Jean-Paul, dira encore que j'suis Au pack)

"Jacquouille" a écrit dans le message de
news:
Allo Jeanne?

--
Bien amicalmement,
Vivement conseillés:
http://www.excelabo.net
http://jacxl.free.fr/mpfe/trombino.html
http://dj.joss.free.fr/netiquet.htm
http://frederic.sigonneau.free.fr/

Jacquouille.

a écrit dans le message de news:

Hi, I have problem with this macro. It tells me " Else sans If" at
this line "Else: If Month(Now()) = 12 Then ThisWorkbook.SaveCopyAs
NomFich2". Whats'wrong?


NomFich = "G:BanquesBanque " & Format(Now(), "yyyy") & "" &
Format(Now(), "dd-mmm-yy") & ".xls"
NomFich2 = "G:BanquesBanque " & Format(Now() + 200, "yyyy") &
"" & Format(Now(), "dd-mmm-yy") & ".xls"
For Each Feuil In ThisWorkbook.Worksheets
Feuil.UsedRange.Copy
Feuil.UsedRange.PasteSpecial xlPasteValues
Application.CutCopyMode = False
Next Feuil

If Month(Now()) = 11 Then ThisWorkbook.SaveCopyAs NomFich2
If Month(Now()) = 12 Then ThisWorkbook.SaveCopyAs
NomFich2
Else: ThisWorkbook.SaveCopyAs NomFich
End If
End If
ThisWorkbook.Saved = True

Thanks mp











Avatar
lSteph
;-)

Oeuf Corse , was pour rester dans le tune!

"jps" a écrit dans le message de news:
%
heu....non pas, non pas, stéphane : je pense que notre liègeois (qui
bravissimus est) veut parler de Jehanne, la bonne Lorraine qu'Anglois
bruslèrent à Rouen
jps (innocent comme une nonne aux pâques)


"lSteph" a écrit dans le message de news:
%
;o)))

Non Jacquouille ( Jane!!!)
--
lSteph

(..et après cela Jean-Paul, dira encore que j'suis Au pack)

"Jacquouille" a écrit dans le message de
news:
Allo Jeanne?

--
Bien amicalmement,
Vivement conseillés:
http://www.excelabo.net
http://jacxl.free.fr/mpfe/trombino.html
http://dj.joss.free.fr/netiquet.htm
http://frederic.sigonneau.free.fr/

Jacquouille.

a écrit dans le message de news:

Hi, I have problem with this macro. It tells me " Else sans If" at
this line "Else: If Month(Now()) = 12 Then ThisWorkbook.SaveCopyAs
NomFich2". Whats'wrong?


NomFich = "G:BanquesBanque " & Format(Now(), "yyyy") & "" &
Format(Now(), "dd-mmm-yy") & ".xls"
NomFich2 = "G:BanquesBanque " & Format(Now() + 200, "yyyy") &
"" & Format(Now(), "dd-mmm-yy") & ".xls"
For Each Feuil In ThisWorkbook.Worksheets
Feuil.UsedRange.Copy
Feuil.UsedRange.PasteSpecial xlPasteValues
Application.CutCopyMode = False
Next Feuil

If Month(Now()) = 11 Then ThisWorkbook.SaveCopyAs NomFich2
If Month(Now()) = 12 Then ThisWorkbook.SaveCopyAs
NomFich2
Else: ThisWorkbook.SaveCopyAs NomFich
End If
End If
ThisWorkbook.Saved = True

Thanks mp















Avatar
Jacquouille
J'en suis tout ésolé, mais Johanne, la blonde pucelle (d'Orléans ?) était
Gauloise et non Bretonne, fût-elle petite ou grande
Je crois que tu confonds avec icelle de Tarzan. -)
Jacquouille, pur et fidèle descendant de Jehanne la pucelle, morte au
bucher.
--
Bien amicalmement,
Vivement conseillés:
http://www.excelabo.net
http://jacxl.free.fr/mpfe/trombino.html
http://dj.joss.free.fr/netiquet.htm
http://frederic.sigonneau.free.fr/

Jacquouille.

"lSteph" a écrit dans le message de news:
%
;o)))

Non Jacquouille ( Jane!!!)
--
lSteph

(..et après cela Jean-Paul, dira encore que j'suis Au pack)

"Jacquouille" a écrit dans le message de
news:
Allo Jeanne?

--
Bien amicalmement,
Vivement conseillés:
http://www.excelabo.net
http://jacxl.free.fr/mpfe/trombino.html
http://dj.joss.free.fr/netiquet.htm
http://frederic.sigonneau.free.fr/

Jacquouille.

a écrit dans le message de news:

Hi, I have problem with this macro. It tells me " Else sans If" at
this line "Else: If Month(Now()) = 12 Then ThisWorkbook.SaveCopyAs
NomFich2". Whats'wrong?


NomFich = "G:BanquesBanque " & Format(Now(), "yyyy") & "" &
Format(Now(), "dd-mmm-yy") & ".xls"
NomFich2 = "G:BanquesBanque " & Format(Now() + 200, "yyyy") &
"" & Format(Now(), "dd-mmm-yy") & ".xls"
For Each Feuil In ThisWorkbook.Worksheets
Feuil.UsedRange.Copy
Feuil.UsedRange.PasteSpecial xlPasteValues
Application.CutCopyMode = False
Next Feuil

If Month(Now()) = 11 Then ThisWorkbook.SaveCopyAs NomFich2
If Month(Now()) = 12 Then ThisWorkbook.SaveCopyAs
NomFich2
Else: ThisWorkbook.SaveCopyAs NomFich
End If
End If
ThisWorkbook.Saved = True

Thanks mp











Avatar
Jacquouille
Tudieu, Jehan de Saint Paul.
Que beau est votre verbe.

--
Bien amicalmement,
Vivement conseillés:
http://www.excelabo.net
http://jacxl.free.fr/mpfe/trombino.html
http://dj.joss.free.fr/netiquet.htm
http://frederic.sigonneau.free.fr/

Jacquouille.

"jps" a écrit dans le message de news:
%
heu....non pas, non pas, stéphane : je pense que notre liègeois (qui
bravissimus est) veut parler de Jehanne, la bonne Lorraine qu'Anglois
bruslèrent à Rouen
jps (innocent comme une nonne aux pâques)


"lSteph" a écrit dans le message de news:
%
;o)))

Non Jacquouille ( Jane!!!)
--
lSteph

(..et après cela Jean-Paul, dira encore que j'suis Au pack)

"Jacquouille" a écrit dans le message de
news:
Allo Jeanne?

--
Bien amicalmement,
Vivement conseillés:
http://www.excelabo.net
http://jacxl.free.fr/mpfe/trombino.html
http://dj.joss.free.fr/netiquet.htm
http://frederic.sigonneau.free.fr/

Jacquouille.

a écrit dans le message de news:

Hi, I have problem with this macro. It tells me " Else sans If" at
this line "Else: If Month(Now()) = 12 Then ThisWorkbook.SaveCopyAs
NomFich2". Whats'wrong?


NomFich = "G:BanquesBanque " & Format(Now(), "yyyy") & "" &
Format(Now(), "dd-mmm-yy") & ".xls"
NomFich2 = "G:BanquesBanque " & Format(Now() + 200, "yyyy") &
"" & Format(Now(), "dd-mmm-yy") & ".xls"
For Each Feuil In ThisWorkbook.Worksheets
Feuil.UsedRange.Copy
Feuil.UsedRange.PasteSpecial xlPasteValues
Application.CutCopyMode = False
Next Feuil

If Month(Now()) = 11 Then ThisWorkbook.SaveCopyAs NomFich2
If Month(Now()) = 12 Then ThisWorkbook.SaveCopyAs
NomFich2
Else: ThisWorkbook.SaveCopyAs NomFich
End If
End If
ThisWorkbook.Saved = True

Thanks mp