Help with End Macro

ckserra

New Member
Joined
Aug 25, 2017
Messages
8
Hi everyone. I deal with a sheet that adds a column each day. I am trying to write a macro that copies and pastes the last column on a different tab. I have struggled with this for a few hours. The macro I have simply selects the row, not the final column. Any help would be fantastic!

Here is the code I am using

Code:
Range("A1", Range("A1").End(xlToRight)).Select

Thanks

Chris
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Hi everyone. I deal with a sheet that adds a column each day. I am trying to write a macro that copies and pastes the last column on a different tab. I have struggled with this for a few hours. The macro I have simply selects the row, not the final column. Any help would be fantastic!
Code:
Range("A1", Range("A1").End(xlToRight)).Select
If you want to select the last column's data, this code line assumes no blank rows or blank columns within the data...
Code:
[table="width: 500"]
[tr]
	[td]Intersect(Cells(1, Columns.Count).End(xlToLeft).EntireColumn, Range("A1").CurrentRegion).Select[/td]
[/tr]
[/table]
 
Upvote 0
If you want to select the last column's data, this code line assumes no blank rows or blank columns within the data...
Code:
[TABLE="width: 500"]
<tbody>[TR]
[TD]Intersect(Cells(1, Columns.Count).End(xlToLeft).EntireColumn, Range("A1").CurrentRegion).Select[/TD]
[/TR]
</tbody>[/TABLE]


Hi Rick. That works great on my example spreadsheet, but wont work on my real sheet since there are blank rows I cannot change or eliminate. Also, is there a way to change which row it sees the last column of data?

Thanks for your help!

Chris
 
Upvote 0
Hi Rick. That works great on my example spreadsheet, but wont work on my real sheet since there are blank rows I cannot change or eliminate. Also, is there a way to change which row it sees the last column of data?
This should work no matter column or row defines the end of the data and no matter how many blank rows or columns there are...
Code:
[table="width: 500"]
[tr]
	[td]With Cells.Find("*", , xlValues, , xlByColumns, xlPrevious)
  Range(Cells(1, .Column), Cells(Cells.Find("*", , xlValues, , xlRows, xlPrevious).Row, .Column)).Select
End With[/td]
[/tr]
[/table]
 
Last edited:
Upvote 0
This should work no matter column or row defines the end of the data and no matter how many blank rows or columns there are...
Code:
[TABLE="width: 500"]
<tbody>[TR]
[TD]With Cells.Find("*", , xlValues, , xlByColumns, xlPrevious)
  Range(Cells(1, .Column), Cells(Cells.Find("*", , xlValues, , xlRows, xlPrevious).Row, .Column)).Select
End With[/TD]
[/TR]
</tbody>[/TABLE]


PERFECT!! Thank you very much!

Chris
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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