Need to Loop through a named range and delete all empty columns/rows

BrianExcel

Well-known Member
Joined
Apr 21, 2010
Messages
975
I have a named range, "FinalEditsRange".

I need to loop through the range and (1) delete all empty columns. Then, I need to loop through the last column in the range (the header is "Percent Edit" and delete any row that is empty or contains 0.

Is it possible to do both in one block of code?
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Use XL2BB and provide us with a small sample of your data and then using the same data manually mock up what you want your solution to look like and post using XL2BB
 
Upvote 0
Here is the data being generated by this report. But when I pull data for different weeks, the data set can change, and so can where the blanks are (if any exist).

This data is what I am trying to test against right now.

Venus Ball Stats (5.25-6.01).xlsx
ABCDEFG
1VenueReadsEditedPercent Edit
2City1338,1021,0260.303%
3City260.00%
4City3
5City417610.568%
6City546,4831600.344%
7City636,5661980.541%
8City7441,3423,2570.738%
9City8
10City9467,6054,4350.948%
11City10
12City111400.00%
13City1222,487970.431%
14City13384,9681,1620.302%
15City14426,9911,1640.273%
16City1525,090870.347%
17City16
18City17384,3573,4860.907%
19City18422,9426840.162%
20City1932,735970.296%
21City20438,7012,5790.588%
7DayEdits
 
Upvote 0
And here is what it looks like when done. All blanks columns removed, and any cell within with "0" or blank, the entire row is removed.

Venus Ball Stats (5.25-6.01).xlsx
ABCD
1VenueReadsEditedPercent Edit
2City1338,1021,0260.303%
3City417610.568%
4City546,4831600.344%
5City636,5661980.541%
6City7441,3423,2570.738%
7City9467,6054,4350.948%
8City1222,487970.431%
9City13384,9681,1620.302%
10City14426,9911,1640.273%
11City1525,090870.347%
12City17384,3573,4860.907%
13City18422,9426840.162%
14City1932,735970.296%
15City20438,7012,5790.588%
7DayEdits
 
Upvote 0
Perfect for Power Query to solve. Here is Mcode.

Rich (BB code):
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Removed Columns" = Table.RemoveColumns(Source,{"Column1", "Column2", "Column3"}),
    #"Filtered Rows" = Table.SelectRows(#"Removed Columns", each ([Percent Edit] <> null and [Percent Edit] <> 0)),
    #"Changed Type" = Table.TransformColumnTypes(#"Filtered Rows",{{"Venue", type text}, {"Reads", Int64.Type}, {"Edited", Int64.Type}}),
    #"Rounded Off" = Table.TransformColumns(#"Changed Type",{{"Percent Edit", each Number.Round(_, 5), type number}}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Rounded Off",{{"Percent Edit", Percentage.Type}})
in
    #"Changed Type1"

Book3
ABCD
1VenueReadsEditedPercent Edit
2City133810210260.303%
3City417610.568%
4City5464831600.344%
5City6365661980.541%
6City744134232570.738%
7City946760544350.948%
8City1222487970.431%
9City1338496811620.302%
10City1442699111640.273%
11City1525090870.347%
12City1738435734860.907%
13City184229426840.162%
14City1932735970.296%
15City2043870125790.588%
Sheet2
 
Upvote 0

Forum statistics

Threads
1,215,008
Messages
6,122,672
Members
449,091
Latest member
peppernaut

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