Live-Forum - Die aktuellen Beiträge
Datum
Titel
28.03.2024 21:12:36
28.03.2024 18:31:49
Anzeige
Archiv - Navigation
848to852
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
848to852
848to852
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

add a characters infront of the values typed in

add a characters infront of the values typed in
21.02.2007 15:32:00
Steve
Hi *,
I'm using some custom functions to write data into a database. I don't know how this happens but I can simply select a cell with one of these custome functions, type in a value and a special plug-in writes the values into the database + restores the function.
Now I wanna add a character automatically infront of the numbers I type into this cell (without destroying the formula). Any ideas how to it?
Thanks.
Greetings,
Steve

4
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: add a characters infront of the values typed in
21.02.2007 18:02:46
stormy_weathers
Hi Steve,
it is easier for us, when you can get a example....
cu
stormy
AW: add a characters infront of the values typed in
21.02.2007 21:12:00
Peter
Hello Steve,
you gave only few information, which cell, which character.
But try this - add the macro into the calls-modul of the sheet, you want to work with
Right click to the sheets register
Left click to show code
than copy the macro and add it to the shown window
close that window
than try


Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
   If Target.Column = 2 Then                ' is it column 2 = B ?
      If Left(Target.Value, 1) <> "X" Then  ' isn't there an X in first position
         Target.Value = "X" & Target.Value  ' so add an X into the first position
      End If
   End If
End Sub }


Peter
Anzeige
AW: add a characters infront of the values typed i
22.02.2007 18:10:26
Steve
Danke Peter!!! Das sieht schonmal gut aus. Leider wird die Formel im nachhinein nicht wieder hergestellt... Ich habe also versucht das folgendermaßen zu lösen:

Private Sub Worksheet_Change(ByVal Target As Range)
Formel = Target.Formula
If Target.Range("N21") Then                ' is it column 2 = B ?
If Left(Target.Value, 1) <> "!" Then  ' isn't there an X in first position
Target.Value = "!" & Target.Value  ' so add an X into the first position
Target.Formula = Formel
End If
End If
End Sub

Leider führt dies zu einer Endlosschleife ;)
Ich probiere weiter... vielleicht habt ihr ja noch eine Idee.
Anzeige
AW: add a characters infront of the values typed in
21.02.2007 21:54:15
Peter
Hello Steve,
in case you prefer a random character (big letters A to Z) try this macro
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Randomize
If Target.Column = 2 Then                ' is it column 2 = B ?
If IsNumeric(Left(Target.Value, 1)) Then
Target.Value = Chr(Asc("@") + Rnd * 25 + 1) & Target.Value
End If
End If
End Sub

Peter

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige