Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

automatisation

5 réponses
Avatar
Fredo(67)
Bonjour,

je publie un tableau Excel directement en html par la fonction Print

voici un extrait du code que j'utilise

---- d=E9but du code ----

Print #1, Chr$(13) & " <tr>"
Print #1, Chr$(13) & " <td width=3D'166'>" & Range("a2").Value & "</td>"
Print #1, Chr$(13) & " <td width=3D'127'>" & Range("b2").Value & "</td>"
Print #1, Chr$(13) & " <td width=3D'307'>" & Range("c2").Value & "</td>"
Print #1, Chr$(13) & " </tr>"
Print #1, Chr$(13) & " <tr>"
Print #1, Chr$(13) & " <td width=3D'166'>" & Range("a3").Value & "</td>"
Print #1, Chr$(13) & " <td width=3D'127'>" & Range("b3").Value & "</td>"
Print #1, Chr$(13) & " <td width=3D'307'>" & Range("c3").Value & "</td>"
Print #1, Chr$(13) & " </tr>"
Print #1, Chr$(13) & " <tr>"
Print #1, Chr$(13) & " <td width=3D'166'>" & Range("a4").Value & "</td>"
Print #1, Chr$(13) & " <td width=3D'127'>" & Range("b4").Value & "</td>"
Print #1, Chr$(13) & " <td width=3D'307'>" & Range("c4").Value & "</td>"
Print #1, Chr$(13) & " </tr>"
---- fin du code ---

sachant que mes donn=E9es vont de la ligne 2 =E0 15

y'aurait il moyen d'optimiser mon code : du style
pour I=3D2 to 15 et ensuite le code en lui disant de reprendre comme num=
=E9ro de ligne la valeur de I

j'ai test=E9 plusieurs truc, mais je m'y perd dans les if then et dans la s=
yntaxe....

MErci de l'aide que vous pourriez m'apporter

5 réponses

Avatar
DanielCo
Bonjour,

For i = 2 To 15
Print #1, Chr$(13) & " <td width='166'>" & Range("a" & i).Value
& "</td>"
Print #1, Chr$(13) & " <td width='127'>" & Range("b" & i).Value
& "</td>"
Print #1, Chr$(13) & " <td width='307'>" & Range("c" & i).Value
& "</td>"
Print #1, Chr$(13) & " </tr>"
Print #1, Chr$(13) & " </tr>"
Next i

Cordialement.
Daniel


Bonjour,

je publie un tableau Excel directement en html par la fonction Print

voici un extrait du code que j'utilise

---- début du code ----

Print #1, Chr$(13) & " <tr>"
Print #1, Chr$(13) & " <td width='166'>" & Range("a2").Value & "</td>"
Print #1, Chr$(13) & " <td width='127'>" & Range("b2").Value & "</td>"
Print #1, Chr$(13) & " <td width='307'>" & Range("c2").Value & "</td>"
Print #1, Chr$(13) & " </tr>"
Print #1, Chr$(13) & " <tr>"
Print #1, Chr$(13) & " <td width='166'>" & Range("a3").Value & "</td>"
Print #1, Chr$(13) & " <td width='127'>" & Range("b3").Value & "</td>"
Print #1, Chr$(13) & " <td width='307'>" & Range("c3").Value & "</td>"
Print #1, Chr$(13) & " </tr>"
Print #1, Chr$(13) & " <tr>"
Print #1, Chr$(13) & " <td width='166'>" & Range("a4").Value & "</td>"
Print #1, Chr$(13) & " <td width='127'>" & Range("b4").Value & "</td>"
Print #1, Chr$(13) & " <td width='307'>" & Range("c4").Value & "</td>"
Print #1, Chr$(13) & " </tr>"
---- fin du code ---

sachant que mes données vont de la ligne 2 à 15

y'aurait il moyen d'optimiser mon code : du style
pour I=2 to 15 et ensuite le code en lui disant de reprendre comme numéro de
ligne la valeur de I

j'ai testé plusieurs truc, mais je m'y perd dans les if then et dans la
syntaxe....

MErci de l'aide que vous pourriez m'apporter
Avatar
Fredo(67)
Effectivement, cela ressemble pas du tout à se sur quoi j'étais partis. ...

vais tester de suite et je te tiens au courant...

Le lundi 2 septembre 2013 11:15:28 UTC+2, Fredo(67) a écrit :
Bonjour,



je publie un tableau Excel directement en html par la fonction Print



voici un extrait du code que j'utilise



---- début du code ----



Print #1, Chr$(13) & " <tr>"

Print #1, Chr$(13) & " <td width='166'>" & Range("a2").Value & "</td >"

Print #1, Chr$(13) & " <td width='127'>" & Range("b2").Value & "</td >"

Print #1, Chr$(13) & " <td width='307'>" & Range("c2").Value & "</td >"

Print #1, Chr$(13) & " </tr>"

Print #1, Chr$(13) & " <tr>"

Print #1, Chr$(13) & " <td width='166'>" & Range("a3").Value & "</td >"

Print #1, Chr$(13) & " <td width='127'>" & Range("b3").Value & "</td >"

Print #1, Chr$(13) & " <td width='307'>" & Range("c3").Value & "</td >"

Print #1, Chr$(13) & " </tr>"

Print #1, Chr$(13) & " <tr>"

Print #1, Chr$(13) & " <td width='166'>" & Range("a4").Value & "</td >"

Print #1, Chr$(13) & " <td width='127'>" & Range("b4").Value & "</td >"

Print #1, Chr$(13) & " <td width='307'>" & Range("c4").Value & "</td >"

Print #1, Chr$(13) & " </tr>"

---- fin du code ---



sachant que mes données vont de la ligne 2 à 15



y'aurait il moyen d'optimiser mon code : du style

pour I=2 to 15 et ensuite le code en lui disant de reprendre comme num éro de ligne la valeur de I



j'ai testé plusieurs truc, mais je m'y perd dans les if then et dans la syntaxe....



MErci de l'aide que vous pourriez m'apporter
Avatar
Fredo(67)
Ok, et bien je te remercie beaucoup
cela marche du tonnerre.

Comment pourrions nous imaginer la chose si on avait une ligne sur 2 qui so it différente.

peut on imbriquer "for to"

ou comment incrémenter de 2 en 2
puis-je faire un i=i+2 au lieu du next i ?





Le lundi 2 septembre 2013 14:26:46 UTC+2, Fredo(67) a écrit :
Effectivement, cela ressemble pas du tout à se sur quoi j'étais parti s....



vais tester de suite et je te tiens au courant...



Le lundi 2 septembre 2013 11:15:28 UTC+2, Fredo(67) a écrit :

> Bonjour,

>

>

>

> je publie un tableau Excel directement en html par la fonction Print

>

>

>

> voici un extrait du code que j'utilise

>

>

>

> ---- début du code ----

>

>

>

> Print #1, Chr$(13) & " <tr>"

>

> Print #1, Chr$(13) & " <td width='166'>" & Range("a2").Value & "</ td>"

>

> Print #1, Chr$(13) & " <td width='127'>" & Range("b2").Value & "</ td>"

>

> Print #1, Chr$(13) & " <td width='307'>" & Range("c2").Value & "</ td>"

>

> Print #1, Chr$(13) & " </tr>"

>

> Print #1, Chr$(13) & " <tr>"

>

> Print #1, Chr$(13) & " <td width='166'>" & Range("a3").Value & "</ td>"

>

> Print #1, Chr$(13) & " <td width='127'>" & Range("b3").Value & "</ td>"

>

> Print #1, Chr$(13) & " <td width='307'>" & Range("c3").Value & "</ td>"

>

> Print #1, Chr$(13) & " </tr>"

>

> Print #1, Chr$(13) & " <tr>"

>

> Print #1, Chr$(13) & " <td width='166'>" & Range("a4").Value & "</ td>"

>

> Print #1, Chr$(13) & " <td width='127'>" & Range("b4").Value & "</ td>"

>

> Print #1, Chr$(13) & " <td width='307'>" & Range("c4").Value & "</ td>"

>

> Print #1, Chr$(13) & " </tr>"

>

> ---- fin du code ---

>

>

>

> sachant que mes données vont de la ligne 2 à 15

>

>

>

> y'aurait il moyen d'optimiser mon code : du style

>

> pour I=2 to 15 et ensuite le code en lui disant de reprendre comme n uméro de ligne la valeur de I

>

>

>

> j'ai testé plusieurs truc, mais je m'y perd dans les if then et dans la syntaxe....

>

>

>

> MErci de l'aide que vous pourriez m'apporter
Avatar
DanielCo
For i = 2 To 15 Step 2

Daniel
Avatar
Fredo(67)
Ben voilà,

C'est parfait.

merci beaucoup.

Le lundi 2 septembre 2013 15:01:49 UTC+2, DanielCo a écrit :
For i = 2 To 15 Step 2



Daniel