Selecting rows from Long

Lallo

New Member
Joined
Sep 28, 2010
Messages
44
I have this piece of code, finding the last row with data in columns A through D:


Dim LR As Long
LR = Columns("A:M").Find("*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row


What I want to do next is to select rows LR+1 through row 600, i.e. everything below the last row down to row #600.

What's the code for this?

Tried this, but it doesn't work:


LR = LR + 1

Range(LR:600").Select


Any ideas?
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Try:

Code:
Rows(LR+1 & ":600").Select
 
Upvote 0
Cheers! Works like a charm!

Now I have another problem though:

I want to hide certain columns; B, D and F, as well as the rows selected as per above.

Here's the code (part of longer code):

Sheets.Add.Name = "shttemp"


Sheets("Sheet3").Select

Dim LR As Long
LR = Columns("A:A").Find("*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row

With ActiveSheet
Sheets("Sheet3").Select
Range("B:B, D:D, F:F").Select

Selection.EntireColumn.Hidden = True

Rows(LR + 1 & ":600").Select
Selection.EntireRow.Hidden = True


Range("A3:M500").Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Sheets("shttemp").Select
Range("A1").Select
ActiveSheet.Pictures.Paste.Select

End With

Sheets("Sheet3").Select
Range("B:B, D:D, F:F").Select
Selection.EntireColumn.Hidden = False

Sheets("Sheet3").Select
Rows(LR + 1 & ":600").Select
Selection.EntireRow.Hidden = False

Sheets("shttemp").Select

Now, it works with the rows, but not with the columns. i.e it pastes all the columns, even the hidden ones. (the columns worked before I started hiding the rows)

Ideas?
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,762
Members
452,940
Latest member
rootytrip

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