selecting all cells even with empty rows...

GS7CLW

Banned
Joined
Aug 10, 2010
Messages
168
I am trying to select (with a macro) the entire WS. The code below would work if there were no empty lines. How can I change it so this macro will select the entire page even with 1 or 2 empty rows.

Code:
lastNameRow = Range("F" & Rows.Count).End(xlUp).Row
ActiveSheet.ListObjects.Add(xlSrcRange, Range("A1:L" & lastNameRow), , xlNo).Name = _
        "Table1"
Range("Table1[#All]").Select

IT'S FRIDAY;>))
hope everyone has a GREAT weekend.
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
I am trying to select (with a macro) the entire WS. The code below would work if there were no empty lines. How can I change it so this macro will select the entire page even with 1 or 2 empty rows.

Code:
lastNameRow = Range("F" & Rows.Count).End(xlUp).Row
ActiveSheet.ListObjects.Add(xlSrcRange, Range("A1:L" & lastNameRow), , xlNo).Name = _
        "Table1"
Range("Table1[#All]").Select

IT'S FRIDAY;>))
hope everyone has a GREAT weekend.


Use
Cells.Select

then you can use Selection.Copy or what ever it is you want to do...
 
Upvote 0
Try

Code:
ActiveSheet.UsedRange.Select

This solves the selection problem!!

What do I need to do with:

Code:
ActiveSheet.ListObjects.Add(xlSrcRange, Range("A1:L" & lastNameRow), , xlNo).Name = _
        "Table1"
Range("Table1[#All]").Select

I have tried:

Code:
[ActiveSheet.ListObjects.Add(xlSrcRange, Range(UsedRange), , xlNo).Name = _
"Table1"
Range("Table1[#All]").Select
 
Upvote 0
I got it:

Code:
LastColumn = ActiveSheet.UsedRange.Column - 1 + _
             ActiveSheet.UsedRange.Columns.Count
LastRow = ActiveSheet.UsedRange.Row - 1 + _
          ActiveSheet.UsedRange.Rows.Count
ActiveSheet.Range(Cells(1, 1), Cells(LastRow, LastColumn)).Select
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1:$L$" & LastRow), , xlNo).Name = "Table1"
Range("Table1[#All]").Select

Thanks EVERYONE!
Have a GREAT weekend.....
 
Upvote 0

Forum statistics

Threads
1,224,534
Messages
6,179,391
Members
452,909
Latest member
VickiS

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