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>
</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 | |
---|---|---|---|---|
1 | ||||
2 | Code | Name | Date | |
3 | ||||
4 | TD20 | THEP TRON Ø20 | 12/4/2014 | |
5 | ||||
6 | TD22 | THEP TRON Ø22 | 11/1/2014 | |
7 | ||||
8 | TD24 | THEP TRON Ø24 | 11/1/2014 | |
9 | ||||
10 | TD26 | THEP TRON Ø28 | 11/1/2014 | |
11 |
<tbody>
</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.