Searching a Range Of Cells

G

Guest

Guest
I Have a sheet with a range of cells that i want to search so that i can find the last cell in the range that contains any data.
ActiveCell.Offset(1, -13) = CODE
Cells.Find(What:="*", After:=[A1], _
SearchDirection:=xlPrevious, LookIn:=xlValues).Select
I am using the above code but this is searching the whole sheet and not just the range of cells that i want to look at within the sheet. These are (c2:t200). Does anyone know the best way to resolve this problem...

Thx
Roy
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
THIS LOOKS SOMEWHAT TO MY CURRENT PROBLEM:
Perhaps the solution (which I do not have) can help us both...

I have a query which runs each month and result in a result consisting of x lines
It is a variable range because the number of lines differs each month.
Now I want to establish a VLOOKUP formula which looks in the entire (variable) range.
It always starts in "A1" but it ends in "Bx"

I have a COUNTA formula which counts the number of lines. (Actually this looks at a large number of lines or the whole column.) Lets suppose this number is 1200.
How can I get the VLOOKUP-formula to automatically take the relevant range "A1:B1200" ?
So, I want Excel to fill in the 1200-value.
Any help on this issue is highly appreciated ! Greetings from the Netherlands !!
 
Upvote 0
On 2002-02-22 02:56, Anonymous wrote:
I Have a sheet with a range of cells that i want to search so that i can find the last cell in the range that contains any data.
ActiveCell.Offset(1, -13) = CODE
Cells.Find(What:="*", After:=[A1], _
SearchDirection:=xlPrevious, LookIn:=xlValues).Select
I am using the above code but this is searching the whole sheet and not just the range of cells that i want to look at within the sheet. These are (c2:t200). Does anyone know the best way to resolve this problem...

Thx
Roy


[C2:T201].Find(What:="*", After:=[T201], _
SearchDirection:=xlPrevious, LookIn:=xlValues).Select
 
Upvote 0
On 2002-02-22 05:38, Dr. Strangelove wrote:
THIS LOOKS SOMEWHAT TO MY CURRENT PROBLEM:
Perhaps the solution (which I do not have) can help us both...

I have a query which runs each month and result in a result consisting of x lines
It is a variable range because the number of lines differs each month.
Now I want to establish a VLOOKUP formula which looks in the entire (variable) range.
It always starts in "A1" but it ends in "Bx"

I have a COUNTA formula which counts the number of lines. (Actually this looks at a large number of lines or the whole column.) Lets suppose this number is 1200.
How can I get the VLOOKUP-formula to automatically take the relevant range "A1:B1200" ?
So, I want Excel to fill in the 1200-value.
Any help on this issue is highly appreciated ! Greetings from the Netherlands !!

You could set your range like this :-

Dim rw As Long, rng As Range
rw = Columns("A:B").Find(What:="*", After:=[B65536], _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row
Set rng = Range([A1], Cells(rw, 2))
 
Upvote 0
does this help?

Sub UsdRange()
Dim LastRow As Integer
Dim FLoop As Integer
Dim LastAddress As String

LastRow = Range(worksheets("sheet1").UsedRange.Address).Rows.Count

For FLoop = 1 To LastRow
If Range("C" & FLoop) = "*" Then
LastAddress = Range("C" & FLoop).Address
End If
Next FLoop
MsgBox LastAddress
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,575
Messages
6,120,344
Members
448,956
Latest member
Adamsxl

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