Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Worksheet Functions / May 2008

Tip: Looking for answers? Try searching our database.

Value a cell based on vlookup results

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
robeck - 21 May 2008 16:34 GMT
I am using vlookup to interrogate a column of cells and if the value I input
is not found in the column I would like to move the input value to the 1st
open cell at the end of the column.  I don't know how to determine what the
1st open cell is without having to list each cell and check if it is blank.  
Is there a way to look for the first cell that is blank? Thanks.
Pete_UK - 21 May 2008 17:25 GMT
A formula cannot move or copy a cell, so you would need a macro to do
what you want to achieve.

Pete

> I am using vlookup to interrogate a column of cells and if the value I input
> is not found in the column I would like to move the input value to the 1st
> open cell at the end of the column.  I don't know how to determine what the
> 1st open cell is without having to list each cell and check if it is blank.  
> Is there a way to look for the first cell that is blank? Thanks.
robeck - 21 May 2008 19:55 GMT
Do I need to write something in Visual Basic?  I have done some macros but
haven't done anything conditional with a macro, is there a way to do that?

> A formula cannot move or copy a cell, so you would need a macro to do
> what you want to achieve.
[quoted text clipped - 6 lines]
> > 1st open cell is without having to list each cell and check if it is blank..  
> > Is there a way to look for the first cell that is blank? Thanks.
Pete_UK - 22 May 2008 00:28 GMT
Perhaps you could explain exactly what you want to do, and give
details like the sheet names involved, the cells you want to work with
and the formula you are using now.

Pete

> Do I need to write something in Visual Basic?  I have done some macros but
> haven't done anything conditional with a macro, is there a way to do that?
[quoted text clipped - 11 lines]
>
> - Show quoted text -
robeck - 22 May 2008 13:38 GMT
Column A contains numerous cells with a project number (for example
200746498).  The number of cells valued can change, right now we have values
in cells A3-A88.  I have named the column projects.  Right now I have a
vlookup statement in cell D2 which reads "VLOOKUP(C2,projects,1,FALSE)" where
I am inputting a project number in cell C2 and checking if that number is
already entered in the projects column (checking for duplicates).  If it is
already there I don't want to do anything with it but if it has not been
entered in the projects column (the formula above returns an NA) I need to
find the first open cell in the column (this could change as projects are
added or deleted) and add the project number to the end of the list.
Thanks for your help.

> Perhaps you could explain exactly what you want to do, and give
> details like the sheet names involved, the cells you want to work with
[quoted text clipped - 17 lines]
> >
> > - Show quoted text -
Bernie Deitrick - 22 May 2008 14:07 GMT
Copy the code below, right-click the sheet tab, select "View Code" and paste the code into the
window that appears.

You can remove or comment out the line

  MsgBox "I just added """ & Target.Value & """ to the list."

if you don't want to be notified when the project list is changed.

You can remove the formula in cell D2 since all it will do in the future is to return the value
entered in C2.

If your named range "projects" is dynamic, then you can remove the lines from On Error Resume Next
to the end.
If it is not dynamic, then those lines will update that named range to include the newest additions.

HTH,
Bernie
MS Excel MVP

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$C$2" Then Exit Sub
If IsError(Application.Match(Target.Value, Range("A:A"), False)) Then
  Application.EnableEvents = False
  Range("A2").End(xlDown)(2).Value = Target.Value
  MsgBox "I just added """ & Target.Value & """ to the list."
  Application.EnableEvents = True
End If

On Error Resume Next
ActiveWorkbook.Names("projects").Delete
ActiveWorkbook.Names.Add Name:="projects", RefersTo:= _
       "='" & Target.Parent.Name & "'!" & Range("A3", Cells(Rows.Count, 1).End(xlUp)).Address

End Sub

> Column A contains numerous cells with a project number (for example
> 200746498).  The number of cells valued can change, right now we have values
[quoted text clipped - 29 lines]
>> >
>> > - Show quoted text -
robeck - 22 May 2008 19:07 GMT
That works (almost), now when I input a project id  in cell C2 (one that is
not already on the list) it adds it in cell A8 which already had a value in
it and continues to add any subsequent ids in cell A8. Thanks so much for
your help so far, it is really appreciated.  

> Copy the code below, right-click the sheet tab, select "View Code" and paste the code into the
> window that appears.
[quoted text clipped - 65 lines]
> >> >
> >> > - Show quoted text -
Bernie Deitrick - 22 May 2008 19:35 GMT
Based on your description, I assumed that your list started in cell A2 with a header value, and then
the actual values started in C3.  Apparently, your first entry is in Cell A8.  You can either
replace the A2 with A8, and A3 with A9, or use

 Cells(Rows.Coount,1).End(xlUp)(2).Value = Target.Value

in place of

 Range("A2").End(xlDown)(2).Value = Target.Value

HTH,
Bernie
MS Excel MVP

> That works (almost), now when I input a project id  in cell C2 (one that is
> not already on the list) it adds it in cell A8 which already had a value in
[quoted text clipped - 72 lines]
>> >> >
>> >> > - Show quoted text -
robeck - 22 May 2008 20:20 GMT
That works great, thank you so much for your help

> Based on your description, I assumed that your list started in cell A2 with a header value, and then
> the actual values started in C3.  Apparently, your first entry is in Cell A8.  You can either
[quoted text clipped - 86 lines]
> >> >> >
> >> >> > - Show quoted text -
Bernie Deitrick - 21 May 2008 17:28 GMT
Select the top cell of the column, then use End-Down ,  Down   and you will arrive at the first
blank cell.

HTH,
Bernie
MS Excel MVP

>I am using vlookup to interrogate a column of cells and if the value I input
> is not found in the column I would like to move the input value to the 1st
> open cell at the end of the column.  I don't know how to determine what the
> 1st open cell is without having to list each cell and check if it is blank.
> Is there a way to look for the first cell that is blank? Thanks.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.