VBA, to read a cell contents and use it as a filter

  • I have written the code below mostly from key stroke macros. I'm stuck at trying to have the variable "machine" read the contents of the cell $B$4 and use it as a filter. The cell $B$4 is a VLOOKUP from a list. The code in question are the 4 lines from the DIM statement. The rest works fine. Any brilliant suggestions?


  • Re: VBA, to read a cell contents and use it as a filter


    Welcome to the forum. :)


    You need:


    Code
    machine = Range("B4").Value


    Ideally you would specify the sheet as well for safety.

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

  • Re: VBA, to read a cell contents and use it as a filter



    Thanks for the welcome and thanks for the code, it worked nicely first time. I'm getting back into using Excel and Access after many years break, been discovering how much I've forgotten, looking forward to learning a bit from the forum.
    Cheers
    Chris

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!