Strona 1 z 1
[VBA] Formatowanie komórek
: 19 sie 2013, o 20:53
autor: hellsing
Czy ktos wie jak zedytowac dokument w Wordzie gdzie wystepuja liczby w formacie
PLN 1,227,086 thousand
PLN 800,944 thousand
etc. na takie zeby byly w formacie
PLN XXX million ?
Czyli potrzebuje makra ktore by zmienilo PLN XXX,XXX thousand na PLN XXX million.
Z gory dzieki.
[VBA] Formatowanie komórek
: 19 sie 2013, o 22:01
autor: zeus_156
Ja bym to zrobił tak:
Kod: Zaznacz cały
Sub SpecjalneZamien()
Selection.Find.ClearFormatting
With Selection.Find
.Text = "PLN [0-9]{1;3}(,[0-9]{1;3})* thousand"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Do
Selection.Find.Execute
If Len(Selection.Text) > 1 Then
Selection.TypeText Text:=Replace(Replace(Selection.Text, ",", ""), "thousand", "million")
Else
MsgBox ("koniec")
Exit Do
End If
Loop While 1
End Sub
[VBA] Formatowanie komórek
: 20 sie 2013, o 13:03
autor: hellsing
Nie do konca dziala. Zamienia PLN XXX,XXX thousand ma PLN XXXXXX million. Chcialbym zeby zamienial PLN 1,234,567 thousand na PLN 1,234 millon. Moglbys tak to zedytowac?
[VBA] Formatowanie komórek
: 20 sie 2013, o 13:28
autor: MakCis
Podejrzewam, że
Kod: Zaznacz cały
Sub SpecjalneZamien()
Selection.Find.ClearFormatting
With Selection.Find
.Text = "PLN [0-9]{1;3}(,[0-9]{1;3})* thousand"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Do
Selection.Find.Execute
If Len(Selection.Text) > 1 Then
Selection.TypeText Text:=Replace(Replace(Selection.Text, ",", ","), "thousand", "million")
Else
MsgBox ("koniec")
Exit Do
End If
Loop While 1
End Sub
[VBA] Formatowanie komórek
: 20 sie 2013, o 22:19
autor: zeus_156
Gdybyś od razu podał ten przykład to było by wiadomo, że chodzi Ci o to:
Kod: Zaznacz cały
Sub SpecjalneZamien()
Dim textLen, substLen
Selection.Find.ClearFormatting
With Selection.Find
.Text = "PLN [0-9]{1;3}(,[0-9]{3})* thousand"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
substLen = Len(",XXX thousand")
Do
Selection.Find.Execute
textLen = Len(Selection.Text)
If textLen > substLen And InStr(Selection.Text, " million") < 1 Then
Selection.TypeText Text:=Mid(Selection.Text, 1, textLen - substLen) & " million"
Else
MsgBox ("koniec")
Exit Do
End If
Loop While 1
End Sub
Dobrze jest też wiedzieć, że gdyby ktoś chciał to uruchomić na angielskiej wersji MS Word-a to trzeba zmienić jedną linijkę na:
Kod: Zaznacz cały
.Text = "PLN [0-9]{1,3}(,[0-9]{3})* thousand"