Home |
Search |
Today's Posts |
#1
![]() |
|||
|
|||
![]()
Hi,
Here's my code: Sub ref() Dim RefNumber As String Dim RefFound As Range Dim LastRow As Long Workbooks("2009 Hourly by res.xlsx").Sheets("Jan-Feb").Activate With ActiveSheet LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row End With RefNumber = Application.InputBox("Reference #", "Meter Point Reference Number") Set RefFound = Cells.Find(What:=RefNumber, After:=ActiveCell, LookIn:=xlFormulas, LookAt _ :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _ False, SearchFormat:=False) Range(Cells(5, RefFound), Cells(LastRow, RefFound)).Select MsgBox "Found Ref # at column" & RefFound.Column MsgBox "and last row at" & LastRow End Sub ---------------------------------------- When i run this code I get a runtime error 1004 (only happens with my range line in) LastRow will be the final row and RefFound.Column is the column for my range. If anyone could help with this I'm having a hard time creating a select range with my variables. Thanks, Chris |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Range variables | Excel Programming | |||
VBA Range Variables... | Excel Programming | |||
Set few range variables at once | Excel Programming | |||
Range of variables | Excel Programming | |||
Range Variables | Excel Programming |