Need cell I7 to equal the last cell in column I in a Macro

JB0903

New Member
Joined
Dec 12, 2013
Messages
6
I need cell I7 to equal the last cell in column I within a macro. I tried to do "=CTRL+END" & got this:

TestI7 Macro
Range("I7").Select
ActiveCell.FormulaR1C1 = "=R[18]C"
Range("I8").Select
End Sub

However, this is giving me the last cell that was in the spreadsheet it was created in, I8. This spreadsheet is very long & the last cell can range from I2000 to I4999. How can I tell the macro I want cell I7 to equal the very last cell no matter what it is each time?
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Try this. Assumes that there is continuous data in all of column I beginning with I1 and ending with I (lastrow).
Always test macros on a COPY of your data, not the original.

Sub TestI7()
Range("I1").Select
Selection.End(xlDown).Select
ActiveCell.Copy
Range("I7").Select
ActiveSheet.Paste
End Sub
 
Upvote 0
No need for all that Selecting:

Code:
Sub test()
Range("I7") = Range("I" & Rows.Count).End(xlUp)
End Sub
 
Upvote 0
Neither seem to be working. @akmatz, the return on that is cell F8. @ Scott, that code is returning nothing. :( My dept uses a VERY large & extremely complocated macro for reporting job costs. With that one, we much pull the raw data report in 2007 & save in 2003. However, we all have 2010! SO...let me see if that might be the problem. I'm not thinking so because I have 15 other macro that are working in the same workbook. It's something small that I am overlooking, I know it!

Thanks guys!
 
Upvote 0
My code doesn't return nothing, it does exactly what you asked for:

If I put the number 15 in I15, and then run my code, it will put 15 in I7.
 
Upvote 0
It was a merged cell, that's why it didn't work. The merged cell was actually H7 instead of I7. Something small I knew it! :eeek: Thank you so very much for your help!

I do have one concern. It is giving me something like a special paste values. The ending cell that will be referenced has a formula. Would this update or should this macro be one of the last ones ran?
 
Upvote 0

Forum statistics

Threads
1,225,657
Messages
6,186,257
Members
453,347
Latest member
mrizkiii28

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