将string添加到单元格而不使用其他列

我试图找出是否有一种方法(公式或其他)在Excel中只是插入一个string到一个单元格和单元格自动更新一个额外的string。 例如,在A1中,我所要做的就是键入“teststring”, 同一个单元格自动更新为“teststring_iscool”。

我想要做的是为其他员工设置CSV以方便数据库上传。 我查看了左/右和连接函数,这些将不起作用,因为数据库在导入期间不会接受随机数据。

这可能吗?

这个给你。 如果A:A列的单元格值发生变化,它将检查它是否以_iscool结尾,如果不是, _iscool附加这个后缀。 注意:将VBA编辑器中的这段代码添加到工作表代码中。

 Const RangeToCheck = "A:A" Const Postfix = "_iscool" Public Function StringEndsWith(ByVal strValue As String, _ CheckFor As String, Optional CompareType As VbCompareMethod _ = vbBinaryCompare) As Boolean Dim sCompare As String Dim lLen As Long lLen = Len(CheckFor) If lLen > Len(strValue) Then Exit Function sCompare = Right(strValue, lLen) StringEndsWith = StrComp(sCompare, CheckFor, CompareType) = 0 End Function Private Sub Worksheet_Change(ByVal Target As Range) If Not Intersect(Range(RangeToCheck), Target) Is Nothing Then 'Check only for changes in A:A column If Not StringEndsWith(Target.Value, Postfix) Then Target.Value = Target.Value & Postfix End If End If End Sub