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

Recherche dune cellule par VBA

3 réponses
Avatar
DM
Bonjour, j<ai recherch/ dans le forum mais sans r/ponse...

Depuis ACCESS j'ouvre un fichier EXCEL à la feuille "Projets" et je veux que
la cellule "TACHES" soir activée.

Voici mon code:

Private Sub Commande1_Click()
On Error GoTo Err_Commande1_Click

'Déclaration des variables
Dim appExcel As Excel.Application 'Application Excel
Dim wbExcel As Excel.Workbook 'Classeur Excel
Dim wsExcel As Excel.Worksheet 'Feuille Excel
'Ouverture de l'application
Set appExcel = CreateObject("Excel.Application")
'Ouverture d'un fichier Excel
Set wbExcel = appExcel.Workbooks.Open("C:\toto.xls")
'wsExcel correspond à la première feuille du fichier
wbExcel.Worksheets("Projets").Select
appExcel.Cells.Find(What:="JOB", After:=ActiveCell, LookIn:=xlFormulas,
_ LookAt:= xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False , SearchFormat:=False).Activate
appExcel.Visible = True

Exit_PCommande1_Click:
Exit Sub

Err_Commande1_Click:
MsgBox Err.description
Resume Exit_Commande1_Click

End Sub
---------------------------------------

Au niveau de appExcel.Cells.Find, message d'erreur "Le serveur distant
n'existe pas ou n'est pas disponible" et terminé!
Si je remplace cette ligne par:
appExcel.Cells(715, 1).Select, il m'ouvre bien le fichier au bon endroit.

Quelqu'un peut-il m'éclaircir sur le pbe?

Merci.

3 réponses

Avatar
AH60
Bonsoir

peut être essaie avec
Set Var= appExcel.Cells.Find(What:="JOB", After:¬tiveCell,
LookIn:=xlFormulas,
_ LookAt:= xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:úlse , SearchFormat:úlse).Activate

Bonne soirée

Abed_H



Bonjour, j<ai recherch/ dans le forum mais sans r/ponse...

Depuis ACCESS j'ouvre un fichier EXCEL à la feuille "Projets" et je veux que
la cellule "TACHES" soir activée.

Voici mon code:

Private Sub Commande1_Click()
On Error GoTo Err_Commande1_Click

'Déclaration des variables
Dim appExcel As Excel.Application 'Application Excel
Dim wbExcel As Excel.Workbook 'Classeur Excel
Dim wsExcel As Excel.Worksheet 'Feuille Excel
'Ouverture de l'application
Set appExcel = CreateObject("Excel.Application")
'Ouverture d'un fichier Excel
Set wbExcel = appExcel.Workbooks.Open("C:toto.xls")
'wsExcel correspond à la première feuille du fichier
wbExcel.Worksheets("Projets").Select
appExcel.Cells.Find(What:="JOB", After:¬tiveCell, LookIn:=xlFormulas,
_ LookAt:= xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:úlse , SearchFormat:úlse).Activate
appExcel.Visible = True

Exit_PCommande1_Click:
Exit Sub

Err_Commande1_Click:
MsgBox Err.description
Resume Exit_Commande1_Click

End Sub
---------------------------------------

Au niveau de appExcel.Cells.Find, message d'erreur "Le serveur distant
n'existe pas ou n'est pas disponible" et terminé!
Si je remplace cette ligne par:
appExcel.Cells(715, 1).Select, il m'ouvre bien le fichier au bon endroit.

Quelqu'un peut-il m'éclaircir sur le pbe?

Merci.



Avatar
JB
Bonsoir,


Dim xl As New Excel.Application
On Error Resume Next
xl.Workbooks.Open FileName:=RépertoireAppli & "modèle_congés.xls"
If Err <> 0 Then
MsgBox "Installer le fichier Modèle_congés.xls dans le répertoire
de l'appplication!"
Exit Sub
End If
xl.Visible = True
xl.ActiveSheet.[k:k].Find(what:="TITI", lookin:=xlValues).Activate

JB





On 5 mar, 22:54, DM wrote:
Bonjour, j<ai recherch/ dans le forum mais sans r/ponse...

Depuis ACCESS j'ouvre un fichier EXCEL à la feuille "Projets" et je veu x que
la cellule "TACHES" soir activée.

Voici mon code:

Private Sub Commande1_Click()
On Error GoTo Err_Commande1_Click

'Déclaration des variables
Dim appExcel As Excel.Application 'Application Excel
Dim wbExcel As Excel.Workbook 'Classeur Excel
Dim wsExcel As Excel.Worksheet 'Feuille Excel
'Ouverture de l'application
Set appExcel = CreateObject("Excel.Application")
'Ouverture d'un fichier Excel
Set wbExcel = appExcel.Workbooks.Open("C:toto.xls")
'wsExcel correspond à la première feuille du fichier
wbExcel.Worksheets("Projets").Select
appExcel.Cells.Find(What:="JOB", After:¬tiveCell, LookIn:=xlF ormulas,
_ LookAt:= xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:úlse , SearchFormat:úlse).Activate
appExcel.Visible = True

Exit_PCommande1_Click:
Exit Sub

Err_Commande1_Click:
MsgBox Err.description
Resume Exit_Commande1_Click

End Sub
---------------------------------------

Au niveau de appExcel.Cells.Find, message d'erreur "Le serveur distant
n'existe pas ou n'est pas disponible" et terminé!
Si je remplace cette ligne par:
appExcel.Cells(715, 1).Select, il m'ouvre bien le fichier au bon endroit.

Quelqu'un peut-il m'éclaircir sur le pbe?

Merci.


Avatar
MichDenis
As-tu essayé de cette manière :

Cette façon de déclarer tes variables te permettra
d'exécuter le code nonobstant la version Excel installée
sur l'ordinateur où s'exécutera la macro

A ) au sujet des déclarations des variables :
Dim appExcel As Object
Dim wbExcel As Object
Dim wsExcel As Object

B ) Modifie la dernière section de ta macro comme ceci:
à partir de la ligne de code :
Set wbExcel = appExcel.Workbooks.Open("C:toto.xls")

'----------------------
Set wbExcel = appExcel.Workbooks.Open("C:toto.xls")
appExcel.Visible = True
With wbExcel
With .Worksheets("Projets")
.Select
.Cells.Find(What:="JOB", After:¬tiveCell, _
LookIn:=xlFormulas, LookAt:= xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:úlse , SearchFormat:úlse).select
End With
End with
'----------------------



"DM" a écrit dans le message de news:

Bonjour, j<ai recherch/ dans le forum mais sans r/ponse...

Depuis ACCESS j'ouvre un fichier EXCEL à la feuille "Projets" et je veux que
la cellule "TACHES" soir activée.

Voici mon code:

Private Sub Commande1_Click()
On Error GoTo Err_Commande1_Click

'Déclaration des variables
Dim appExcel As Excel.Application 'Application Excel
Dim wbExcel As Excel.Workbook 'Classeur Excel
Dim wsExcel As Excel.Worksheet 'Feuille Excel
'Ouverture de l'application
Set appExcel = CreateObject("Excel.Application")
'Ouverture d'un fichier Excel
Set wbExcel = appExcel.Workbooks.Open("C:toto.xls")
'wsExcel correspond à la première feuille du fichier
wbExcel.Worksheets("Projets").Select
appExcel.Cells.Find(What:="JOB", After:¬tiveCell, LookIn:=xlFormulas,
_ LookAt:= xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:úlse , SearchFormat:úlse).Activate
appExcel.Visible = True

Exit_PCommande1_Click:
Exit Sub

Err_Commande1_Click:
MsgBox Err.description
Resume Exit_Commande1_Click

End Sub
---------------------------------------

Au niveau de appExcel.Cells.Find, message d'erreur "Le serveur distant
n'existe pas ou n'est pas disponible" et terminé!
Si je remplace cette ligne par:
appExcel.Cells(715, 1).Select, il m'ouvre bien le fichier au bon endroit.

Quelqu'un peut-il m'éclaircir sur le pbe?

Merci.