Hello,
Here are some comments :
‘executes when a value is entered in a cell (or the cell contents are
deleted)
Private Sub Worksheet_Change(ByVal Target As Range)
‘only if the value is entered in cell C3
If Target.Row = 3 And Target.Column = 3 Then
'calculate criteria cell in case calculation mode is manual
Worksheets("ProductsList").Range("I3").Calculate
‘uses advanced filter, results in columns A:G, from row 6 downward
Worksheets("ProductsList").Range("Database") _
.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheets("ProductsList").Range("I2:I3"), _
CopyToRange:=Range("A6:G6"), Unique:=False
End If
End Sub
‘if another range is selected (maybe the filter result ?)
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
‘if column is G and row > 6
If Target.Column = 7 And Target.Row > 6 Then
‘if cell being on the same row in column A <> ””
If Cells(Target.Row, 1).Value <> "" Then
‘change target value to “X”
Target.Value = "X"
‘macro ?
MoveRow
'MsgBox "Row has been copied"
End If
End If
End Sub
Regards.
Daniel
De : excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com] De
la part de neil johnson
Envoyé : vendredi 15 juillet 2011 13:50
À : excel-macros; Dave Bonallack; Dilip Pandey
Objet : $$Excel-Macros$$ there are two code , please explain this code.
Hi,
I need your help . I have query in VBA. Please help me
.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 3 And Target.Column = 3 Then
'calculate criteria cell in case calculation mode is manual
Worksheets("ProductsList").Range("I3").Calculate
Worksheets("ProductsList").Range("Database") _
.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheets("ProductsList").Range("I2:I3"), _
CopyToRange:=Range("A6:G6"), Unique:=False
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 7 And Target.Row > 6 Then
If Cells(Target.Row, 1).Value <> "" Then
Target.Value = "X"
MoveRow
'MsgBox "Row has been copied"
End If
End If
End Sub
--
--
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links :
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
To post to this group, send email to excel-macros@googlegroups.com
<><><><><><><><><><><><><><><><><><><><><><>
Like our page on facebook , Just follow below link
http://www.facebook.com/discussexcel
--
--
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links :
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
To post to this group, send email to excel-macros@googlegroups.com
<><><><><><><><><><><><><><><><><><><><><><>
Like our page on facebook , Just follow below link
http://www.facebook.com/discussexcel