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

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.
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,223,785
Messages
6,174,539
Members
452,571
Latest member
MarExcelTips

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