如何通过VBA循环在Userform中将TextBox值添加到另一个工作表的许多单元格中。
通过循环一个字符串值,如何使用vba取回该字符串的每个字符值?
Private Sub saveBtn_Click()
Dim ws As Worksheet
Dim staffId As String
Dim counter As Integer
FileDir = Module1.copyFilesToTemp(ThisWorkbook.Path)
staffId = TextBox3.Value
Set ws = getWorksheet(ThisWorkbook, "TempSheet")
With ws
.Cells(3, 26).Value = TextBox1.Text
.Cells(5, 13).Value = TextBox2.Text
'// Here is the point I want to get back each character values
For counter = 1 To Len(staffId)
.Range("M6").Value = Mid(staffId, counter, 1)
.Range("N6").Value = Mid(staffId, counter, 2)
.Range("O6").Value = Mid(staffId, counter, 2)
.Range("P6").Value = Mid(staffId, counter, 2)
.Range("Q6").Value = Mid(staffId, counter, 2)
.Range("R6").Value = Mid(staffId, counter, 2)
.Range("S6").Value = Mid(staffId, counter, 2)
.Range("T6").Value = Mid(staffId, counter, 2)
Next
.Cells(7, 13).Value = TextBox4.Text
.Cells(16, 1).Value = TextBox5.Text
.Cells(16, 2).Value = TextBox6.Text
.Cells(16, 4).Value = TextBox7.Text
.Cells(16, 10).Value = TextBox8.Text
.Cells(16, 13).Value = TextBox9.Text
.Cells(16, 29).Value = TextBox10.Text
End With
End Sub