sir i explain project my userform contain 2 macro. every time enter data data will be add in worksheet "DATA" in last blank rows every time.
Macro 1 is "FillDocCenterAmount"
Macro 2 is "FillDateSenderFrom"
i need Result show as below after 2 macro runs
| |
BARODA | DELHI
|
BARODA | BHARUCH
|
BARODA | SURAT
|
BARODA | SAVLI
|
BARODA | NAVSARI
|
<colgroup><col style="mso-width-source:userset;mso-width-alt:3108;width:64pt" width="85"> <col style="mso-width-source:userset;mso-width-alt:4352;width:89pt" width="119"> <col style="mso-width-source:userset;mso-width-alt:3218;width:66pt" width="88"> <col style="mso-width-source:userset;mso-width-alt:3328;width:68pt" width="91"> <col style="mso-width-source:userset;mso-width-alt:3949;width:81pt" width="108"> <col style="mso-width-source:userset;mso-width-alt:3108;width:64pt" width="85"> </colgroup><tbody>
[TD="class: xl64, width: 85"] DATE
[/TD]
[TD="class: xl64, width: 119"] SENDER
[/TD]
[TD="class: xl64, width: 88"]FROM[/TD]
[TD="class: xl64, width: 91"]DOC NO[/TD]
[TD="class: xl64, width: 108"] CENTER
[/TD]
[TD="class: xl64, width: 85"]AMOUNT[/TD]
[TD="class: xl63, align: right"]03/11/2018
[/TD]
[TD="class: xl63"] KALPESH
[/TD]
[TD="align: right"]132455456
[/TD]
[TD="align: right"]50[/TD]
[TD="class: xl63, align: right"]03/11/2018
[/TD]
[TD="class: xl63"] KALPESH
[/TD]
[TD="align: right"]132455457
[/TD]
[TD="align: right"]30[/TD]
[TD="class: xl63, align: right"]03/11/2018
[/TD]
[TD="class: xl63"] KALPESH
[/TD]
[TD="align: right"]132455458[/TD]
[TD="align: right"]30
[/TD]
[TD="class: xl63, align: right"]03/11/2018[/TD]
[TD="class: xl63"] KALPESH
[/TD]
[TD="align: right"]132455459[/TD]
[TD="align: right"]30
[/TD]
[TD="class: xl63, align: right"]03/11/2018[/TD]
[TD="class: xl63"] KALPESH
[/TD]
[TD="align: right"]132455460[/TD]
[TD="align: right"]30[/TD]
</tbody>
Sub FillDocCenterAmount()
Dim i As Integer
For i = 4 To 8
If Controls("TextBox" & i) <> "" Then
If Worksheets("DATA").Range("D1").Offset(1, 0).Value = "" Then
Worksheets("DATA").Range("D1").Offset(1, 0).Value = Controls("TextBox" & i).Text
Else
Worksheets("DATA").Range("D1").End(xlDown).Offset(1, 0).Value = Controls("TextBox" & i).Text
End If
End If
Next i
For i = 9 To 13
If Controls("TextBox" & i) <> "" Then
If Worksheets("DATA").Range("E1").Offset(1, 0).Value = "" Then
Worksheets("DATA").Range("E1").Offset(1, 0).Value = Controls("TextBox" & i).Text
Else
Worksheets("DATA").Range("E1").End(xlDown).Offset(1, 0).Value = Controls("TextBox" & i).Text
End If
End If
Next i
For i = 14 To 18
If Controls("TextBox" & i) <> "" Then
If Worksheets("DATA").Range("F1").Offset(1, 0).Value = "" Then
Worksheets("DATA").Range("F1").Offset(1, 0).Value = Controls("TextBox" & i).Text
Else
Worksheets("DATA").Range("F1").End(xlDown).Offset(1, 0).Value = Controls("TextBox" & i).Text
End If
End If
Next i
End Sub
Sub FillDateSenderFrom()
For i = 1 To 3
If Controls("TextBox" & i) <> "" Then
If i = 1 Then
Worksheets("DATA").Activate
Cells(Rows.Count, 2).End(xlUp).End(xlToLeft).Offset(0, i - 1).Select
Range(ActiveCell, ActiveCell.End(xlUp).Offset(1, 0)).Value = Controls("TextBox" & i).Text
Else
Cells(Rows.Count, 2).End(xlUp).End(xlToLeft).Offset(0, 1).Select
Range(ActiveCell, ActiveCell.End(xlUp).Offset(1, 0)).Value = Controls("TextBox" & i).Text
End If
End If
Next i
End Sub