Problème avec Instr
Résolu
pseudo_polo
-
eriiic Messages postés 24603 Date d'inscription Statut Contributeur Dernière intervention -
eriiic Messages postés 24603 Date d'inscription Statut Contributeur Dernière intervention -
Bonjour,
Mon souci est d'arriver à extraire automatiquement le caractère "variablexx" des éléments de la formule ci-dessous:
=IF($B18=0," ",VLOOKUP($S18&$B$11&"Retail Sales Final"&" "&Ind!$CO$4,variablexx!$A$1:$AR$626,Ind!I$43,FALSE))
Je souhaite en effet utiliser cette variable (ici, variablexx) pour remplacer ce que je veux. Le problème est que je bugge!!!
Comment dire recherche p ex la troisième virgule de la formule, et prends les x caractère avant le "!"????
regardez mon code à partir de y = ActiveCell.FormulaR1C1Local !!!
je souhaite en fait que y prenne variablexx par macro, mais je bugge!!
Public Sub test_v2()
Dim lngLeft As Long, lngRight As Long, lngCommaPos As Long, lngptPos As Long
Dim i, bb As Integer
Range("A65000").Select
ActiveCell.End(xlUp).Offset(1, 0).Select
Row1 = ActiveCell.Row
For Each c In Worksheets("xxxx").Range("t14:t" & Row1 - 1).Cells
c.Select
'If c.Value = "bibi" Or c.Value = "toto" Then
If c.Value <> "" Then
c.Select
j = ActiveCell.Row
y = ActiveCell.FormulaR1C1Local
y = Replace(y, "'", "")
totalLength = Len(y)
someVar = InStr(y, "Ind!")
theResult = Right(y, totalLength - someVar)
lngCommaPos = InStr(1, y, "Ind!")
' lngptPos = InStr(1, y, ",")
y = Right(y, lngCommaPos)
lngptPos = InStr(1, y, ",")
aa = Mid(y, lngptPos + 5, 35)
cc = Range("b" & j).Value
If cc <> aa Then
Range(Selection, Selection.End(xlToRight)).Select
Selection.Replace What:=aa, Replacement:=cc, LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End If
End If
Next
End Sub
Merci bcp par avance!!!! et bonne semaine!!
pseudo_polo
Mon souci est d'arriver à extraire automatiquement le caractère "variablexx" des éléments de la formule ci-dessous:
=IF($B18=0," ",VLOOKUP($S18&$B$11&"Retail Sales Final"&" "&Ind!$CO$4,variablexx!$A$1:$AR$626,Ind!I$43,FALSE))
Je souhaite en effet utiliser cette variable (ici, variablexx) pour remplacer ce que je veux. Le problème est que je bugge!!!
Comment dire recherche p ex la troisième virgule de la formule, et prends les x caractère avant le "!"????
regardez mon code à partir de y = ActiveCell.FormulaR1C1Local !!!
je souhaite en fait que y prenne variablexx par macro, mais je bugge!!
Public Sub test_v2()
Dim lngLeft As Long, lngRight As Long, lngCommaPos As Long, lngptPos As Long
Dim i, bb As Integer
Range("A65000").Select
ActiveCell.End(xlUp).Offset(1, 0).Select
Row1 = ActiveCell.Row
For Each c In Worksheets("xxxx").Range("t14:t" & Row1 - 1).Cells
c.Select
'If c.Value = "bibi" Or c.Value = "toto" Then
If c.Value <> "" Then
c.Select
j = ActiveCell.Row
y = ActiveCell.FormulaR1C1Local
y = Replace(y, "'", "")
totalLength = Len(y)
someVar = InStr(y, "Ind!")
theResult = Right(y, totalLength - someVar)
lngCommaPos = InStr(1, y, "Ind!")
' lngptPos = InStr(1, y, ",")
y = Right(y, lngCommaPos)
lngptPos = InStr(1, y, ",")
aa = Mid(y, lngptPos + 5, 35)
cc = Range("b" & j).Value
If cc <> aa Then
Range(Selection, Selection.End(xlToRight)).Select
Selection.Replace What:=aa, Replacement:=cc, LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End If
End If
Next
End Sub
Merci bcp par avance!!!! et bonne semaine!!
pseudo_polo
1 réponse
Bonjour,
Merci d'éviter les doublons.
Voir ici : https://forums.commentcamarche.net/forum/affich-26462327-probleme-pour-extraire-une-variable-dans-une-formule
eric
Merci d'éviter les doublons.
Voir ici : https://forums.commentcamarche.net/forum/affich-26462327-probleme-pour-extraire-une-variable-dans-une-formule
eric