Skip Action if filter do not have any value

Jasvindra

New Member
Joined
Jul 31, 2018
Messages
38
Hi Team,

I am using the below code but the problem is if column is blank(BE). It pastes the value of BF after the last row upto last excel column. is there any way to skip if filter do not have any value as I am using this condition for multiple columns


ActiveSheet.Range("$A2:$CI2").AutoFilter Field:=57, Criteria1:="<>"
Range("BE" & .Offset(1, 0).SpecialCells(xlCellTypeVisible)(1).Row).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Formula = "=$BF$1"
Range("BE2").Activate
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
How about
Code:
Dim lr As Long
lr = Range("A" & Rows.count).End(xlUp).Row
ActiveSheet.Range("$A2:$CI2").AutoFilter Field:=57, Criteria1:="<>"
On Error Resume Next
Range("BE3:BE" & lr).SpecialCells(xlCellTypeVisible).Formula = "=$BF$1"
On Error GoTo 0
 
Upvote 0

Forum statistics

Threads
1,224,813
Messages
6,181,117
Members
453,021
Latest member
Justyna P

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