So on my first tab I have general grant info. When a new grant is added that's not on my Financial tab, I added a simple Vlookup to indicate that the macro needs to run to add the grant to the financial page. That way we can easily determine if the grant needs to be added to the Financial tab or not. What I want to happen is when the Add Grant macro is run it will get the new grant and add it to the Financial tab like below highlighted Financial Tab.
Process will be: user inputs new grant data on Info tab. user clicks add grant button (which will take the new grant and add it to the financial page with each Type, again example below.)
I think that the Macro could do an "if then statement" that would read:
IF column M says "Please add grant" THEN insert 5 rows named Expenditures, Revenues, etc. and copy grant number from Info Column D (Agency Grant Number) and paste in Column D in Financials.
Info Tab:
[TABLE="class: cms_table_grid"]
<tbody>[TR]
[TD]Department
[/TD]
[TD]PP Grant Number
[/TD]
[TD]Agency Grant #
[/TD]
[TD]CFDA
[/TD]
[TD]Added
[/TD]
[/TR]
[TR]
[TD]560[/TD]
[TD]GTX000001[/TD]
[TD]TX-00-001[/TD]
[TD][/TD]
[TD]Added[/TD]
[/TR]
[TR]
[TD]560[/TD]
[TD]GTX000002[/TD]
[TD]TX-00-002[/TD]
[TD][/TD]
[TD]Added[/TD]
[/TR]
[TR]
[TD]560
[/TD]
[TD]GTX000003
[/TD]
[TD]TX-00-003
[/TD]
[TD][/TD]
[TD]Please Add Grant
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Financial tab:
[TABLE="class: cms_table_grid"]
<tbody>[TR]
[TD]Type
[/TD]
[TD]Department
[/TD]
[TD]PP Grant Number
[/TD]
[TD]Agency Grant #
[/TD]
[TD]Sept.
[/TD]
[/TR]
[TR]
[TD]Expenditure[/TD]
[TD]560[/TD]
[TD]GTX000001[/TD]
[TD]TX-00-001[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Revenue[/TD]
[TD]560[/TD]
[TD]GTX000001[/TD]
[TD]TX-00-001[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]PI[/TD]
[TD]560[/TD]
[TD]GTX000001[/TD]
[TD]TX-00-001[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]In Kind[/TD]
[TD]560[/TD]
[TD]GTX000001[/TD]
[TD]TX-00-001[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Grant Match[/TD]
[TD]560[/TD]
[TD]GTX000001[/TD]
[TD]TX-00-001[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Expenditure[/TD]
[TD]560[/TD]
[TD]GTX000002[/TD]
[TD]TX-00-002[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Revenue[/TD]
[TD]560[/TD]
[TD]GTX000002[/TD]
[TD]TX-00-002[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]PI[/TD]
[TD]560[/TD]
[TD]GTX000002[/TD]
[TD]TX-00-002[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]In Kind[/TD]
[TD]560[/TD]
[TD]GTX000002[/TD]
[TD]TX-00-002[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Grant Match[/TD]
[TD]560[/TD]
[TD]GTX000002[/TD]
[TD]TX-00-002[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Expenditure
[/TD]
[TD][/TD]
[TD][/TD]
[TD]TX-00-003[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Revenue
[/TD]
[TD][/TD]
[TD][/TD]
[TD]TX-00-003[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]PI
[/TD]
[TD][/TD]
[TD][/TD]
[TD]TX-00-003[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]In Kind
[/TD]
[TD][/TD]
[TD][/TD]
[TD]TX-00-003[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Grant Match
[/TD]
[TD][/TD]
[TD][/TD]
[TD]TX-00-003[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
I have the below code but:
1) I need to figure out a way to have it look at if Column E needs to be added and then Copy and Paste (if then)
2) It needs to also add in Expenditure, Revenue, etc.
Please excuse me, I tried!
Process will be: user inputs new grant data on Info tab. user clicks add grant button (which will take the new grant and add it to the financial page with each Type, again example below.)
I think that the Macro could do an "if then statement" that would read:
IF column M says "Please add grant" THEN insert 5 rows named Expenditures, Revenues, etc. and copy grant number from Info Column D (Agency Grant Number) and paste in Column D in Financials.
Info Tab:
[TABLE="class: cms_table_grid"]
<tbody>[TR]
[TD]Department
[/TD]
[TD]PP Grant Number
[/TD]
[TD]Agency Grant #
[/TD]
[TD]CFDA
[/TD]
[TD]Added
[/TD]
[/TR]
[TR]
[TD]560[/TD]
[TD]GTX000001[/TD]
[TD]TX-00-001[/TD]
[TD][/TD]
[TD]Added[/TD]
[/TR]
[TR]
[TD]560[/TD]
[TD]GTX000002[/TD]
[TD]TX-00-002[/TD]
[TD][/TD]
[TD]Added[/TD]
[/TR]
[TR]
[TD]560
[/TD]
[TD]GTX000003
[/TD]
[TD]TX-00-003
[/TD]
[TD][/TD]
[TD]Please Add Grant
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Financial tab:
[TABLE="class: cms_table_grid"]
<tbody>[TR]
[TD]Type
[/TD]
[TD]Department
[/TD]
[TD]PP Grant Number
[/TD]
[TD]Agency Grant #
[/TD]
[TD]Sept.
[/TD]
[/TR]
[TR]
[TD]Expenditure[/TD]
[TD]560[/TD]
[TD]GTX000001[/TD]
[TD]TX-00-001[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Revenue[/TD]
[TD]560[/TD]
[TD]GTX000001[/TD]
[TD]TX-00-001[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]PI[/TD]
[TD]560[/TD]
[TD]GTX000001[/TD]
[TD]TX-00-001[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]In Kind[/TD]
[TD]560[/TD]
[TD]GTX000001[/TD]
[TD]TX-00-001[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Grant Match[/TD]
[TD]560[/TD]
[TD]GTX000001[/TD]
[TD]TX-00-001[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Expenditure[/TD]
[TD]560[/TD]
[TD]GTX000002[/TD]
[TD]TX-00-002[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Revenue[/TD]
[TD]560[/TD]
[TD]GTX000002[/TD]
[TD]TX-00-002[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]PI[/TD]
[TD]560[/TD]
[TD]GTX000002[/TD]
[TD]TX-00-002[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]In Kind[/TD]
[TD]560[/TD]
[TD]GTX000002[/TD]
[TD]TX-00-002[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Grant Match[/TD]
[TD]560[/TD]
[TD]GTX000002[/TD]
[TD]TX-00-002[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Expenditure
[/TD]
[TD][/TD]
[TD][/TD]
[TD]TX-00-003[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Revenue
[/TD]
[TD][/TD]
[TD][/TD]
[TD]TX-00-003[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]PI
[/TD]
[TD][/TD]
[TD][/TD]
[TD]TX-00-003[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]In Kind
[/TD]
[TD][/TD]
[TD][/TD]
[TD]TX-00-003[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Grant Match
[/TD]
[TD][/TD]
[TD][/TD]
[TD]TX-00-003[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
I have the below code but:
1) I need to figure out a way to have it look at if Column E needs to be added and then Copy and Paste (if then)
2) It needs to also add in Expenditure, Revenue, etc.
Please excuse me, I tried!
Code:
Sub CandP()
Dim Last_Row1 As Long, Last_Row2 As Long
Dim ws1 As Worksheet, ws2 As Worksheet
Set ws1 = ActiveWorkbook.Sheets("Department Information") ' Change the name of your Sheet
Set ws2 = ActiveWorkbook.Sheets("Financial") ' Change the name of your Sheet
If Range("L:L") = "Please add grant" Then
Last_Row1 = ws1.Range("A" & Rows.Count).End(xlUp).Row ' Determine the lastrow of the data to copy
Last_Row2 = ws2.Range("D" & Rows.Count).End(xlUp).Row + 1 ' Determine the next empty row in order to paste the data
ws1.Range("C" & Last_Row1).Copy ws2.Range("D" & Last_Row2)
End If
End Sub