VBA Auto filter & amending values help

Gtwist

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

so basically i have the following table
ABCD
1StartDurationDepartMonth
201/11/20196101/01/2020January
301/12/20191819/12/2019December
419/12/20192614/01/2020January
525/12/2019530/12/2019December
630/11/20194312/01/2020January
721/12/20191101/01/2020January
802/11/20191921/11/2019November
915/11/20192712/12/2019December

<tbody>
</tbody>

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
ABCD
StartDurationDepartMonth
101/11/20196101/01/2020January
419/12/20192614/01/2020January
630/11/20194312/01/2020January
721/12/20191101/01/2020January

<tbody>
</tbody>

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

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
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,214,653
Messages
6,120,750
Members
448,989
Latest member
mariah3

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