Variable in Range Selection

JStellato

Board Regular
Joined
Nov 6, 2010
Messages
55
Hello,

I have sort Code
Code:
Dim LastRow3 As String
Dim Col3 As Long
Col3 = 2

LastRow3 = FindLastRow(Col3)

Range("B7:i" + LastRow3).Sort Key1:=Range("B7"), Order1:=xlAscending, Key2:=Range("B8"), Order2:=xlDescending

Function FindLastRow(ByVal Col As Integer) As Long
FindLastRow = Cells(Rows.Count, Col).End(xlUp).Row
End Function
The odd thing is, this doesn't throw an error, it just doesn't work. However if I change this line:

Code:
LastRow3 = FindLastRow(Col3)
to say...
Code:
LastRow3 = 200
It works fine. I'm so confused, am I missing something simple?

Thanks
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Forum statistics

Threads
1,224,590
Messages
6,179,756
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