2017-02-17 80 views
0

我有一種將來自VBA UserForm的輸入信息添加到專用單元格的表單。名字,姓氏,我使用iRow = ws.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).Row查找空行,並在行的特定列中添加信息。默認情況下,信息打印在B1上,可以將其更改爲G7嗎?從特定列和單元格開始添加UserForm的值

Dim iRow As Long 
Dim ws As Worksheet 
Set ws = Worksheets("Sheet1") 

    ws.Cells(iRow, 2).Value = Me.txt_firstname 
    ws.Cells(iRow, 3).Value = Me.txt_lastname 

回答

2

更改您的行數到這一點:

iRow = ws.Cells(Rows.Count, 7).End(xlUp).Offset(1, 0).Row 

If iRow<7 then 
iRow =7 
End if 

ws.Cells(iRow, 7).Value = Me.txt_firstname 

這將改變你的細胞數至少排7,如果第一個單元是晚於後,將其添加到下一個空行之後。

+1

謝謝皮特! :) –

相關問題