Identify and select range, then sort, then transpose copy to another sheet then use VLOOKUP

mdeshazo

New Member
Joined
Dec 30, 2002
Messages
17
Here's the sequence of events and below is the spreadsheet and my poor attempt at code thus far.

I'd really like to have the code execute the macro code directly after the user pastes the information into the workbook.

I will have the user always cut-n-paste information into C35, similar to below, in columns C:J, the rows are variable (could be more or less).

After identifying the range, I then need to sort so that it sorts ascending in column D (to move the budget marked with a "P" to the top), then sort the remaining budgets in ascending order based on the budget number.

After doing this, need to name a range beginning in C37 so that it can then be used for several purposes throughout the rest of the workbook (specifically in a series of VLOOKUP formulas.)

Ok that's my first attempt at explaining this. I can't even get past the identifying the the range I want, much less the next few steps. Note that I have been scouring the board for the last 4 days and have pieced together things that have not worked for me, so I know I'm missing something fundamental here but it escapes me.

Thank you for any assistance,
Michael D.





Excel Workbook
ABCDEFGHIJ
34IF there are sub-budgets,
35PASTE GRANT TRACKER SCREEN HERE >>>>BudgetAwardRevenueExpendituresEncumbranceBalanceReceipt
36610346S$373,502.00($373,502.00)$373,502.00$0.00$0.00$0.00
371Sort Column D as Ascending (moves P to top of list), then sort budget#610362S$58,409.00($58,409.00)$58,409.00$0.00$0.00$0.00
382create a list of budgets to transpose to F&A Checklist!$AE3610844S$29,646.00($29,646.00)$29,646.00$0.00$0.00$0.00
393also copy/paste Total Expenditure data to F&A Checklist!$AE7611297S$47,797.00($47,797.00)$47,797.00$0.00$0.00$0.00
404also copy/paste Total Expenditure data to Info Display!$H21611886S$74,511.00($74,511.00)$74,511.00$0.00$0.00$0.00
415Copy Exp to FA Checklist612116S$18,865.00($18,865.00)$18,865.00$0.00$0.00$0.00
42612291S$4,548.00($4,548.00)$4,548.00$0.00$0.00$0.00
43612354S$203,464.00($203,464.00)$203,414.71$0.00$49.29$0.00
44612430S$21,881.00($21,881.00)$21,881.00$0.00$0.00$0.00
45612550S$19,314.00($19,314.00)$19,314.00$0.00$0.00$0.00
46612706S$36,315.00($36,315.00)$36,315.00$0.00$0.00$0.00
47FirstBudgetRow = C36612710S$2,496.00($2,496.00)$2,496.00$0.00$0.00$0.00
48612713S$34,644.00($34,644.00)$34,644.00$0.00$0.00$0.00
49612715S$22,176.00($22,176.00)$22,176.00$0.00$0.00$0.00
50612740S$307,348.00($307,348.00)$307,348.06$0.00($0.06)$0.00
51612741S$169,361.00($169,361.00)$169,361.00$0.00$0.00$0.00
52612742S$483,099.00($483,099.00)$456,238.94$27,228.26($368.20)$0.00
53613879S$63,833.00($63,833.00)$63,833.00$0.00$0.00$0.00
54613880S$9,951.00($9,951.00)$9,951.00$0.00$0.00$0.00
55614015S$9,831.00($9,831.00)$9,831.00$0.00$0.00$0.00
56614581S$31,455.00($31,455.00)$31,455.00$0.00$0.00$0.00
57614714S$215,879.00($215,879.00)$215,879.00$0.00$0.00$0.00
58629423S$150,781.00($150,781.00)$150,781.00$0.00$0.00$0.00
59629442S$290,770.00($290,770.00)$290,770.00$0.00$0.00$0.00
60629452S$227,761.00($227,761.00)$227,760.63$0.00$0.37$0.00
61629453S$263,384.00($263,384.00)$263,384.00$0.00$0.00$0.00
62629465S$133,638.00($133,638.00)$133,638.00$0.00$0.00$0.00
63629616S$422,390.00($422,390.00)$503,246.23$0.00($80,856.23)$0.00
64629617S$1,767,491.00($1,767,491.00)$1,809,417.40$0.00($41,926.40)$0.00
65629618S$803,311.00($803,311.00)$925,356.77$0.00($122,045.77)$0.00
66629619S$167,892.00($167,892.00)$167,892.00$0.00$0.00$0.00
67629620S$150,000.00($150,000.00)$149,964.22$1.00$34.78$0.00
68629621S$169,920.00($169,920.00)$169,924.53$0.00($4.53)$0.00
69629622S$66,962.00($66,962.00)$66,962.00$0.00$0.00$0.00
70629623S$242,219.00($242,219.00)$242,219.00$0.00$0.00$0.00
71629624S$210,079.00($210,079.00)$210,079.00$0.00$0.00$0.00
72629625S$263,462.00($263,462.00)$263,462.00$0.00$0.00$0.00
73629626S$360,308.00($360,308.00)$360,308.00$0.00$0.00$0.00
74629627S$400,367.00($400,367.00)$400,367.00$0.00$0.00$0.00
75629628S$271,785.00($271,785.00)$271,785.00$0.00$0.00$0.00
76629629S$186,488.00($186,488.00)$186,488.00$0.00$0.00$0.00
77629630S$204,140.00($204,140.00)$204,140.00$0.00$0.00$0.00
78629631S$241,424.00($241,424.00)$241,424.00$0.00$0.00$0.00
79629639S$239,000.00($239,000.00)$279,081.08$0.00($40,081.08)$0.00
80650451S$470.00($470.00)$490.75$0.00($20.75)$470.00
81650452S$66,329.32($66,329.32)$68,248.43$0.00($1,919.11)$4,285.58
82650453S$17,470.55($17,470.55)$19,431.42$0.00($1,960.87)$51.06
83629416629416P$422,681.00($422,681.00)$147,354.19$74,986.95$200,339.86$0.00
DATA INPUT ONLY


The code (attached to the worksheet):
Sub DefineBudgetList()
Dim LR1 As Integer
Dim SortRange1 As Range
Dim SR1 As Integer
Dim BudgetList As Range

' identify the last row of the copied range
LR1 = Range("C65536").End(xlUp).Row
Set SortRange1 = Range("C35:C" & LR1).Resize(, 8).Select
'Set SortRange1 = Range(Cells(35, "C"), Cells(Cells(Rows.Count, "C").End(xlUp).Row, "C"))
With Sheets("DATA INPUT ONLY")
.SortFields.Clear
.SortFields. _
Add Key:=Range("D36:D" & LR1), SortOn:=xlSortOnValues, _
Order:=xlAscending, DataOption:=xlSortNormal
.SortFields. _
Add Key:=Range("C36:C" & LR1), SortOn:=xlSortOnValues, _
Order:=xlAscending, DataOption:=xlSortTextAsNumbers
.SetRange Range("C35:J" & LR1)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Forum statistics

Threads
1,215,740
Messages
6,126,586
Members
449,319
Latest member
iaincmac

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