Ignore cell value

Lauraswint

Board Regular
Joined
Aug 27, 2010
Messages
87
I have a report in which if a certain value is in the cell I would like it to be ignored.

e.g column B if cell value _ Cha then ignore it
if value = anything else then complete action


This is the code currently

Code:
'machine
With Sheets("Sheet1")
    lr = .Cells(Rows.Count, "l").End(xlUp).Row
    .Range("l3:L" & lr).Copy Destination:=Sheets("Sheet2").Range("B6")
End With
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Try like this

Code:
Dim LR As Long
With Sheets("Sheet1")
    LR = .Cells(Rows.Count, "L").End(xlUp).Row
    .Range("B1:B" & LR).AutoFilter field:=1, Criteria1:="<>_ Cha"
    .Range("L3:L" & LR).SpecialCells(xlCellTypeVisible).Copy Destination:=Sheets("Sheet2").Range("B6")
    .Range("B1:B" & LR).AutoFilter
End With
 
Upvote 0
Try like this

Code:
Dim LR As Long
With Sheets("Sheet1")
    LR = .Cells(Rows.Count, "L").End(xlUp).Row
    .Range("B1:B" & LR).AutoFilter field:=1, Criteria1:="<>_ Cha"
    .Range("L3:L" & LR).SpecialCells(xlCellTypeVisible).Copy Destination:=Sheets("Sheet2").Range("B6")
    .Range("B1:B" & LR).AutoFilter
End With


I have tried this but I am getting a compile error on the DIM LR As long

Says Duplicate declaration in current scope.

No idea what this means??? Arghhhhhh
 
Upvote 0
Progress but it has now moved to the first range statement with a runtime error 1004 Application defined or object defined error

Thank you for your help ;-)
 
Upvote 0
This is what I tested without error

Excel Workbook
BCDEFGHIJKL
1
2
3_ Cha1
42
53
6_ Cha4
75
86
9_ Cha7
Sheet1



Code:
Sub test()
Dim LR As Long
With Sheets("Sheet1")
    LR = .Cells(Rows.Count, "L").End(xlUp).Row
    .Range("B1:B" & LR).AutoFilter field:=1, Criteria1:="<>_ Cha"
    .Range("L3:L" & LR).SpecialCells(xlCellTypeVisible).Copy Destination:=Sheets("Sheet2").Range("B6")
    .Range("B1:B" & LR).AutoFilter
End With
End Sub

Result

Excel Workbook
B
1
2
3
4
5
62
73
85
96
Sheet2
 
Upvote 0

Forum statistics

Threads
1,224,616
Messages
6,179,911
Members
452,949
Latest member
beartooth91

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