PDA

View Full Version : VBA Suchen und Ersetzen



AndreasBess
08-18-2014, 07:14 AM
Hallo zusammen,

WENN ICH Anstätt Zellenverweis Zahlen verwende Geht der Kodex.

ICH müsste hier Aber einen Verweis zellen ersetzen. Hat hier Jemand EINE Idee ?



Sub tst ()
Dim r As Range Mit Sheets ("Kalkulation Stammdaten")
Set r = .Range ("M1: M1000")
r.Replace War: = "! Eingabemaske $ P $ 7", Ersatz :. = Range ("K2") Wert, LookAt :. = XlPart
r.Replace War: =, Ersatz "Eingabemaske $ P $ 8!": .. = Range ("K3") Wert, LookAt: = xlPart
r.Replace War: "Eingabemaske $ P $ 9" =, Ersatz :. = Range ("K4") Wert, LookAt :. = XlPart
End Mit
End Sub sterben formeln variieren Immer. Nur der Zellenbezug IST Gleich. Bsp. = Eingabemaske! $ P $ 7 * 0,49 / 1000 = Eingabemaske! $ P $ 7 * 0,14 / 784 = Eingabemaske! $ P $ 7 * 0,98452 / 452 ICH danke Euch für Den Rat

HaHoBe
08-18-2014, 09:22 AM
Hallo, AndreasBess,

Du solltest vilelicht in einem englisch-sprachigen Forum die Frage auf englisch stellen, wenn Du zeitnah eine Antowrt erhalten möchtest.

VBA spricht ebenso wie ein Großteil der Teilnehmer an diesem Forum englisch, und mölglicherweise solltest Du per Makro-Rekorder die Schritte aufzeichnen, um eine Grundlage für den Code und die Anweisungen zu erhalten.

Den Satz nach dem End Sub habe ich leider nicht verstanden und kann ihn daher auch nicht im Code umsetzen

---
Hi, Andreas,

you should consiuder that most participanmts of VBA Express are people who understand english but only a small percentage will care to answer to a thread in German.

Same goes for most of the keywords that are being used in VBA Code: they are in english and you would need them in that way to work. Maybe it would be a good idea to record some basic features with the macro-recorder turned on and have a look at the code which is produced (it could be worked on to be more efficient).

Sorry I didn´t get the meaning of the words after the End Sub so I´m afraid I couldn´t code for that.


Sub tst()
Dim r As Range
Set r = Sheets("Kalkulation Stammdaten").Range("M1:M1000")

With Sheets("Eingabemaske")
r.Replace What:=.Range("P7").Value, Replace:=.Range("K2").Value, LookAt:=xlPart
r.Replace What:=.Range("P8").Value, Replace:=.Range("K3").Value, LookAt:=xlPart
r.Replace What:=.Range("P9").Value, Replace:=.Range("K4").Value, LookAt:=xlPart
End With

Set r = Nothing

End Sub

Sub tst_Loop()
Dim r As Range
Dim lngLoop As Long

Set r = Sheets("Kalkulation Stammdaten").Range("M1:M1000")

With Sheets("Eingabemaske")
For lngLoop = 7 To 9
r.Replace What:=.Range("P" & lngLoop).Value, Replace:=.Range("K" & lngLoop - 5).Value, LookAt:=xlPart
Next lngLoop
End With

Set r = Nothing

End Sub
HTH,
Holger