+ Reply to Thread
Results 1 to 9 of 9

VBA that looks up for a place in table and then write data

  1. #1
    Registered User
    Join Date
    02-18-2014
    Location
    oxford uk
    MS-Off Ver
    Excel 2010
    Posts
    8

    VBA that looks up for a place in table and then write data

    Hi all,

    First off, I am sorry for the title that is probably not clear. I have recently started to understand what VBA does and why it can be powerful. However, I have never learnt programming, and I find it a bit difficult to suss out. I would therefore be really grateful if someone could help on this.

    I have indeed looked up for solutions in tutorials, books etc. and i have not come across a solution for this:

    What I would like is basically a code that makes a workbook to run a sort of log book, or similarly behaves like an inventory.

    I would need a bit of code, that looks up in table using an ID #, and write data in the right cell.
    The purpose of this is for consulting and UPDATING matters in order for users to access information based on an id, and also update the information from a dashboard rather than going to the database.

    I find it a bit difficult to explain... I hope the document I have attached will make sense.
    The code I have written so far is just what a classic vlook up would do, but since i need to update the fields, I need these to contain my content and not the formulas. (Hence i need VBA)

    I have put some more details in the spreadsheet.

    I would be extremely grateful if somebody could give me a hand on the code, point out a tutorial / forum post etc.

    Cheers,

    pierre
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: VBA that looks up for a place in table and then write data

    Hi
    You need to use application.worksheetfunction.match(lookup value, range to look in,false) this will give you the row number

    then cells (row, column) = data

    My VBA is not working at the moment, computer needs rebuilding, so i cant mock up, if i can i will soon.
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Registered User
    Join Date
    02-18-2014
    Location
    oxford uk
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: VBA that looks up for a place in table and then write data

    Hi Nathan,

    Thanks very much for your message. Let me try it. I'll get back to you if I struggle.

    Cheers!

    pierre

  4. #4
    Registered User
    Join Date
    02-18-2014
    Location
    oxford uk
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: VBA that looks up for a place in table and then write data

    Hi Nathan,

    I didn't manage to make it work...

    Here's the code:

    x is the cell where the user inputs id number
    Range(A2, C9) is where the database is ( including id number)
    Sheet2.Range(D7) is where i'd like the value to be copied


    Please Login or Register  to view this content.
    It returns an error message that says "assignment to constant not permitted".

    can please you advise ?

    cheers,

  5. #5
    Registered User
    Join Date
    02-18-2014
    Location
    oxford uk
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: VBA that looks up for a place in table and then write data

    Hi Nathan,

    Have you got a bit of time for me?

    I still haven't found how to make it work.

  6. #6
    Registered User
    Join Date
    02-18-2014
    Location
    oxford uk
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: VBA that looks up for a place in table and then write data

    Anyone else ?

  7. #7
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: VBA that looks up for a place in table and then write data

    Application.WorksheetFunction.Match(x, Sheet2.Range(A2, C9), False) = n


    Wrong way round

    should be

    n= Application.WorksheetFunction.Match(x, Sheet2.Range(A2, C9), False)

  8. #8
    Registered User
    Join Date
    02-18-2014
    Location
    oxford uk
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: VBA that looks up for a place in table and then write data

    Hi Nathan,

    This is now working!! Thank you very much for your help.


    Cheers

  9. #9
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: VBA that looks up for a place in table and then write data

    no worries, had some time off so sorry took a while to get back.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] trying to write a vba that will copy a formula result and place it in another cell as text
    By Shellybelly in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-02-2014, 08:12 AM
  2. Place Data Table in different sheet to raw data?
    By Aland2929 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-08-2013, 01:28 PM
  3. VBA: Read cell number and write it in correct place in a .txt
    By ropbasuel in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-27-2013, 09:12 PM
  4. [SOLVED] VBA: Read cell name and write it on the perfect place in a .txt
    By ropbasuel in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-16-2013, 06:33 PM
  5. Replies: 1
    Last Post: 03-31-2012, 03:29 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1