Using a Variable Within a Variable

  • I have a simple VBA macro I'm using to populate cells based on the values of other cells on the sheets. My code had greatly grown in size, however, and everytime the form needs to be updated it is incredibly painful to go through and update the cell and column references line by line.


    Instead of referencing specific rows and column, I'd like to be able to define variables and reference the variables in the rest of the code to save me some time when updates are needed. I've been playing around with it, but haven't been able to figure it out because the column is variable (and my VBA skills are very limited). Any help and/or suggestions?


    Here is a sample of the code I'm using.


    Thanks!!

  • Hello,


    Is there a specific reason which leads you to use an Event macro ...?


    From your description, a standard macro would probably make your life easier ...


    Hope this will hlep

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Thumbs Up" icon, below, in the bottom right corner:)

  • StephenR - I would like to define Range("E15:J15") as a variable, as well as Cells(16,c), Cells(20,c) etc.


    Carim - I am using an event macro because the code is used in a data entry form. I only want the code to run when certain cells have been changed to prevent the modification of existing data entry values.


    Thanks!!

Participate now!

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