Macro to select last cell in another sheet

wizardmagu

Board Regular
Joined
Dec 27, 2012
Messages
58
Office Version
  1. 365
Platform
  1. Windows
I am trying to reference the last cell containing data in the "DT_Data" sheet. I recorded the macro and pressed "Ctrl+↓) to select it, but it is referencing that same cell. I pasted a different date range and now will only go as far as the information had when I recorded the macro. Any help would be greatly appreciated



Range("B2").Select
ActiveCell.FormulaR1C1 = "='DT_ Data'!R[49]C[-1]"
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Maybe:
Code:
Sub Test()
    Range("B2") = Sheets("DT_ Data").Cells(Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row, Cells.Find("*", , , , xlByColumns, xlPrevious).Column)
End Sub
 
Upvote 0
I am trying to reference the last cell containing data in the "DT_Data" sheet. I recorded the macro and pressed "Ctrl+↓) to select it, but it is referencing that same cell. I pasted a different date range and now will only go as far as the information had when I recorded the macro. Any help would be greatly appreciated



Range("B2").Select
ActiveCell.FormulaR1C1 = "='DT_ Data'!R[49]C[-1]"

Range("B2").Value = Sheets("DT_Date").Range("A1").End(xlDown).Row

Replace the bold A with any column that will always have a value in every cell all the way to the last row.
 
Upvote 0
The macro I suggested will return the value of the last used cell in the sheet into B2.
 
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,392
Members
449,081
Latest member
JAMES KECULAH

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