Hi, I am new to VBA and this is the first time I post a thread in the forum. Hope you in the forum help me.
I have trouble with one problem. Sorry for my bad English
I have data containing 3 columns Code, Name and Date with alternate blank rows as below. I want a code that can automatically insert more a blank row down when I enter data into yellow highlighted blank rows.
<tbody>
[TD="align: center"]1[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #00B0F0, align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]2[/TD]
[TD="align: right"][/TD]
[TD="align: center"]3[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #FFFF00, align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]4[/TD]
[TD="align: right"]12/4/2014[/TD]
[TD="align: right"][/TD]
[TD="align: center"]5[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #FFFF00, align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]6[/TD]
[TD="align: right"]11/1/2014[/TD]
[TD="align: right"][/TD]
[TD="align: center"]7[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #FFFF00, align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]8[/TD]
[TD="align: right"]11/1/2014[/TD]
[TD="align: right"][/TD]
[TD="align: center"]9[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #FFFF00, align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]10[/TD]
[TD="align: right"]11/1/2014[/TD]
[TD="align: right"][/TD]
[TD="align: center"]11[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
</tbody>
First thing, I want people in the forum please explain what is the meaning of Target(2) and the usage of it.
Secondly, if possible, is there any other solution for this problem? I wanna see your other solutions.
Thanks in advance.
I have trouble with one problem. Sorry for my bad English
I have data containing 3 columns Code, Name and Date with alternate blank rows as below. I want a code that can automatically insert more a blank row down when I enter data into yellow highlighted blank rows.
B | C | D | E | |
---|---|---|---|---|
Code | Name | Date | ||
TD20 | THEP TRON Ø20 | |||
TD22 | THEP TRON Ø22 | |||
TD24 | THEP TRON Ø24 | |||
TD26 | THEP TRON Ø28 | |||
<tbody>
[TD="align: center"]1[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #00B0F0, align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]2[/TD]
[TD="align: right"][/TD]
[TD="align: center"]3[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #FFFF00, align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]4[/TD]
[TD="align: right"]12/4/2014[/TD]
[TD="align: right"][/TD]
[TD="align: center"]5[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #FFFF00, align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]6[/TD]
[TD="align: right"]11/1/2014[/TD]
[TD="align: right"][/TD]
[TD="align: center"]7[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #FFFF00, align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]8[/TD]
[TD="align: right"]11/1/2014[/TD]
[TD="align: right"][/TD]
[TD="align: center"]9[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #FFFF00, align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]10[/TD]
[TD="align: right"]11/1/2014[/TD]
[TD="align: right"][/TD]
[TD="align: center"]11[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
</tbody>
Sheet1
A online friend helped me create this code but no explain his code for me.
Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Not Intersect(Target, [D2:D1000]) Is Nothing Then
Application.EnableEvents = False
If Target(2) <> "" Then Target(2).EntireRow.Insert
Application.EnableEvents = True
End If
End Sub
First thing, I want people in the forum please explain what is the meaning of Target(2) and the usage of it.
Secondly, if possible, is there any other solution for this problem? I wanna see your other solutions.
Thanks in advance.