如何获取 VBA 上字符串的前 8 个字符?
How can I get the first 8 characters of a string on VBA?
我想知道如何将 Excel 宏范围内字符串的前 8 个(或任意数字)字符放入变量中。
我有这段代码,但我找不到如何在这些范围内获取特定数量的字符。
sourceBook.Sheets(1).Name = sourceBook.Sheets(1).Range("first_name") & " - " & sourceBook.Sheets(1).Range("last_name")
使用 Left 功能,例如
Public Function func(s As String, n As Integer) As String
'returns the first n characters of a string
func = Left$(s, n)
End Function
我想知道如何将 Excel 宏范围内字符串的前 8 个(或任意数字)字符放入变量中。
我有这段代码,但我找不到如何在这些范围内获取特定数量的字符。
sourceBook.Sheets(1).Name = sourceBook.Sheets(1).Range("first_name") & " - " & sourceBook.Sheets(1).Range("last_name")
使用 Left 功能,例如
Public Function func(s As String, n As Integer) As String
'returns the first n characters of a string
func = Left$(s, n)
End Function