Fill and Sort

kenpcli

Board Regular
Joined
Oct 24, 2017
Messages
129
How do I get it to keep filling in the location number? It breaks after it fills the first site.


47Totals For MEDICARE RR$37,253.00-$15,900.45-$20,182.52$0.00$1,170.03
47Totals For MOLINA$0.00$0.00$0.00$0.00$0.00
47Totals For MULTIPLAN$9,156.00-$4,661.86-$1,026.14$0.00$3,468.00
47Totals For SELF PAY$80,687.75-$38,452.48-$37,242.02$149.40$5,142.65
47Totals For TRICARE$39,590.00-$18,544.17-$12,423.73$921.20$9,543.30
47Totals For UNITED HEALTHCARE$237,266.00-$153,616.60-$65,164.26$1,515.56$20,000.70
47Totals For VETERANS ADMIN$23,748.00-$10,461.24-$10,419.76$0.00$2,867.00
Totals For Albuquerque$3,661,122.75-$1,683,474.79-$1,780,094.21$16,942.84$214,496.59
Bellevue
#N/ATotals For AETNA$504,981.00-$312,837.07-$173,143.99$8,490.26$27,490.20
#N/ATotals For CIGNA$201,832.00-$137,141.51-$43,931.99$546.69$21,305.19
#N/ATotals For COMMERCIAL$314,544.00-$221,865.05-$27,915.65$0.00$64,763.30
#N/ATotals For COMMERCIAL FOUNDATIONS
$11,292.00-$3,000.00$0.00$0.00$8,292.00

<colgroup><col><col><col><col span="2"><col><col></colgroup><tbody>
</tbody>


Sub FillDownLookup()


Dim Ar As Areas
Dim Rng As Range
Dim ValU As Long

With Sheets("Analysis")
Set Ar = .Range("A6:A" & .Range("C" & Rows.Count).End(xlUp).row).SpecialCells(xlBlanks).Areas
For Each Rng In Ar
Rng.Value = Evaluate("VLookup(" & Rng.Offset(-1).Resize(1).Address & ",'LEGEND SITE'!A1:B20, 2, False)")
Next Rng
.Columns(1).Insert
With Columns(2)
.SpecialCells(xlConstants, xlTextValues).EntireRow.Delete
End With
.Sort.SortFields.Clear
.Sort.SortFields.Add Key:=.Range("C6", .Range("C" & Rows.Count).End(xlUp)) _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With .Sort
.SetRange Range("B6:H" & Range("B" & Rows.Count).End(xlUp).row)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End With
End Sub
 
It was a typo in my original code. When I added the With Statement, I obviously missed that bit.
If the "Analysis" sheet is active, it should work, otherwise it might not depending on what is in Col B.
 
Upvote 0

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
I didn't realize you wrote the code originally - but I found the thread from back in November.
I'll let you handle it then!;)
 
Upvote 0

Forum statistics

Threads
1,215,372
Messages
6,124,532
Members
449,169
Latest member
mm424

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