Named Range Info Help

Dr.Evil925

New Member
Joined
Feb 24, 2011
Messages
22
I have a macro that sets a range named FoundCell.
Code:
Dim FoundCell As Range
Set FoundCell = .Find(what:=cbCust.Value, LookIn:=xlValues, lookat:=xlWhole, MatchCase:=faulse)
How can i access the cell locations in it so i can change them, or reference them later in my code?

example
if "FoundCell" is range A1:A5 how can i see that info first, second how can i change that to A1:A10?:confused:

Thanks in advance.
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
FoundCell will only be a single cell. Try

Rich (BB code):
Dim FoundCell As Range
Set FoundCell = .Find(what:=cbCust.Value, LookIn:=xlValues, lookat:=xlWhole, MatchCase:=False)
If Not FoundCell Is Nothing Then MsgBox FoundCell.Address(False, False)
 
Upvote 0
You could assign it to a variable

Code:
Dim FoundCell As Range, s As String
Set FoundCell = .Find(what:=cbCust.Value, LookIn:=xlValues, lookat:=xlWhole, MatchCase:=False)
If Not FoundCell Is Nothing Then s = FoundCell.Address(False, False)

But why not just use FoundCell directly?
 
Upvote 0
I have a row of "customers" and under each of them is a list of names. I am trying to find the first open cell under the customer picked by a combobox so i can add a new name to the list.
 
Upvote 0
Try like this

Code:
Dim FoundCell As Range, s As String
Set FoundCell = .Find(what:=cbCust.Value, LookIn:=xlValues, lookat:=xlWhole, MatchCase:=False)
If Not FoundCell Is Nothing Then FoundCell.Offset(1).Value = "New Customer"
 
Upvote 0
That works for the first name but if I have 2 or 3 names in the list already?
How can i get it to insert into an open cell, which might be row 2,3,4...?
 
Upvote 0
Try like this

Code:
Range("A" & Rows.Count).End(xlUp).Offset(1).Value = "New Customer"
 
Upvote 0
It isn't clear what you are trying to do. The last bit of code that I posted will add a value in the next empty row in column A.
 
Upvote 0

Forum statistics

Threads
1,224,506
Messages
6,179,159
Members
452,892
Latest member
yadavagiri

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