filtering and updating

MAMIBUSSOL

Board Regular
Joined
Jun 2, 2011
Messages
95
I have the following layout

A B C D
date supplier Type Liq

21JUN A 10
21JUN B 10
19JUN C
19JUN D 10

i need to filter out the blanks in column D
update column C with text

so when I remove the filter I should end up with the following based on the above example

A B C D
date supplier type Liq

21JUN A text 10
21JUN B text 10
19JUN C
19JUN D text 10

I can perform this manually but I would rather do this with coding? Any ideas?

I have the following coding to perform the filter, however I am unsure how to do the update part

Code:
    Cells.Select
    Selection.AutoFilter
    ActiveSheet.Range("$A$1:$IC$46").AutoFilter Field:=8, Criteria1:="<>"
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Try:

Code:
Sub Test()
    Dim Sh As Worksheet
    Dim Rng As Range
    Set Sh = Worksheets("Sheet1")
    With Sh
        Set Rng = .Range("A1").CurrentRegion
        Rng.AutoFilter
        Rng.AutoFilter Field:=4, Criteria1:="<>"
        With .AutoFilter.Range.Columns(3)
            .Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible).Value = "text"
        End With
        .AutoFilterMode = False
    End With
End Sub
 
Upvote 0
thanks andrew however I have just hit a snag

Code:
    Selection.AutoFilter
    ActiveSheet.Range("$A$1:$IF$131").AutoFilter Field:=2, Criteria1:="<>"
    ActiveSheet.Range("$B$1:$IE$388").AutoFilter Field:=3, Criteria1:="="
    ActiveSheet.Range("$B$1:$IC$388").AutoFilter Field:=8, Criteria1:="<>"
 
'the above filters out the data
'the code below I thank you for
 
    With ActiveSheet.AutoFilter.Range.Columns(3)
        .Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible).Value = "A"
    End With

the problem is if the filter comes back with no data which is possible, It won't allow me; correctly I might add, to update column C with the value "text". I guess what I need is to bypass this line, when required. I hope this makes sense.
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,282
Members
452,902
Latest member
Knuddeluff

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