VBA Auto filter & amending values help

Gtwist

New Member
Joined
Oct 27, 2019
Messages
1
Hi All,

so basically i have the following table [TABLE="width: 351"]
<tbody>[TR]
[TD][/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"]Start[/TD]
[TD="align: center"]Duration[/TD]
[TD="align: center"]Depart[/TD]
[TD="align: center"]Month[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"]01/11/2019[/TD]
[TD="align: center"]61[/TD]
[TD="align: center"]01/01/2020[/TD]
[TD="align: center"]January[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: center"]01/12/2019[/TD]
[TD="align: center"]18[/TD]
[TD="align: center"]19/12/2019[/TD]
[TD="align: center"]December[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: center"]19/12/2019[/TD]
[TD="align: center"]26[/TD]
[TD="align: center"]14/01/2020[/TD]
[TD="align: center"]January[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]25/12/2019[/TD]
[TD="align: center"]5[/TD]
[TD="align: center"]30/12/2019[/TD]
[TD="align: center"]December[/TD]
[/TR]
[TR]
[TD="align: center"]6[/TD]
[TD="align: center"]30/11/2019[/TD]
[TD="align: center"]43[/TD]
[TD="align: center"]12/01/2020[/TD]
[TD="align: center"]January[/TD]
[/TR]
[TR]
[TD="align: center"]7[/TD]
[TD="align: center"]21/12/2019[/TD]
[TD="align: center"]11[/TD]
[TD="align: center"]01/01/2020[/TD]
[TD="align: center"]January[/TD]
[/TR]
[TR]
[TD="align: center"]8[/TD]
[TD="align: center"]02/11/2019[/TD]
[TD="align: center"]19[/TD]
[TD="align: center"]21/11/2019[/TD]
[TD="align: center"]November[/TD]
[/TR]
[TR]
[TD="align: center"]9[/TD]
[TD="align: center"]15/11/2019[/TD]
[TD="align: center"]27[/TD]
[TD="align: center"]12/12/2019[/TD]
[TD="align: center"]December[/TD]
[/TR]
</tbody>[/TABLE]

so im currently using the following Vba to filter the data

Range("A1:D9").Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$D$9").AutoFilter Field:=3, Criteria1:= _
">12/31/2019", Operator:=xlAnd

which leaves me with the following
[TABLE="width: 351"]
<tbody>[TR]
[TD="align: center"][/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[/TR]
[TR]
[TD="align: center"][/TD]
[TD="align: center"]Start[/TD]
[TD="align: center"]Duration[/TD]
[TD="align: center"]Depart[/TD]
[TD="align: center"]Month[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"]01/11/2019[/TD]
[TD="align: center"]61[/TD]
[TD="align: center"]01/01/2020[/TD]
[TD="align: center"]January[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: center"]19/12/2019[/TD]
[TD="align: center"]26[/TD]
[TD="align: center"]14/01/2020[/TD]
[TD="align: center"]January[/TD]
[/TR]
[TR]
[TD="align: center"]6[/TD]
[TD="align: center"]30/11/2019[/TD]
[TD="align: center"]43[/TD]
[TD="align: center"]12/01/2020[/TD]
[TD="align: center"]January[/TD]
[/TR]
[TR]
[TD="align: center"]7[/TD]
[TD="align: center"]21/12/2019[/TD]
[TD="align: center"]11[/TD]
[TD="align: center"]01/01/2020[/TD]
[TD="align: center"]January[/TD]
[/TR]
</tbody>[/TABLE]

so what im actually after is a vba code to amend the value in the current visible cells in column D from January to 2020, is this possible to do in the one sheet or would i need to copy the current visible data to new sheet make the amends then remove the original data and paste this over


thanks for any help given in advance!
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Welcome to the MrExcel board!

See if this does what you want. Test with a copy of your workbook.

If it is not what you want, please give more details and explain exactly what you mean by "amend the value in the current visible cells in column D from January to 2020"

Rich (BB code):
Sub Test1()
  With Range("A1:D9")
    .AutoFilter Field:=3, Criteria1:=">12/31/2019"
    If .Columns(1).SpecialCells(xlVisible).Count > 1 Then
      .Columns(4).Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlVisible).Value = 2020
    End If
    .AutoFilter Field:=3
  End With
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top