+ Reply to Thread
Results 1 to 9 of 9

How do you set a variable to equal the value of a cell?

  1. #1
    Registered User
    Join Date
    07-08-2013
    Location
    Fort Wayne, IN
    MS-Off Ver
    Excel 2010
    Posts
    61

    How do you set a variable to equal the value of a cell?

    I have ran into an issue when trying to set a variable to equal the value of a particular cell. The code I have written for it is shown below:
    Please Login or Register  to view this content.
    I am trying to use the ActiveCell.Offset command because the cell that I am want the value from isn't always L1225. (Depending on user input)>

    Thank you for the help.

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,613

    Re: How do you set a variable to equal the value of a cell?

    Depending on user input....
    Which is what, exactly?
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    07-08-2013
    Location
    Fort Wayne, IN
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: How do you set a variable to equal the value of a cell?

    When the macro runs, a user is asked if information on sheet 1 is relevant; if yes, the information on that sheet is copied and pasted to the current sheet (CODESHEET UNSORTED). There are 15 sheets prompted and each one can be answered yes or no.

    At the bottom of the CODESHEET UNSORTED, all of the copied data is summed and the values are compared to a bid summary sheet to make sure the user didn't forget to include any sheets with information on them.

    That is what this will eventually be used for (conditional formatting to ensure the values match) but I can't figure out how to set that value as a variable to use throughout the conditional formatting.

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: How do you set a variable to equal the value of a cell?

    Does this help?

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-08-2013
    Location
    Fort Wayne, IN
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: How do you set a variable to equal the value of a cell?

    I changed the code I had :
    Please Login or Register  to view this content.
    to this:
    Please Login or Register  to view this content.
    And it still errors with 'identifier under cursor is no recognized'.

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: How do you set a variable to equal the value of a cell?

    Did you activate the sheet first?

  7. #7
    Registered User
    Join Date
    07-08-2013
    Location
    Fort Wayne, IN
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: How do you set a variable to equal the value of a cell?

    I didn't before because I thought it had already been the 'active sheet.'

    I just activated the sheet and it worked.

    What does that command do? I thought that I wouldn't need it because I was already on CODESHEET UNSORTED prior to starting that command line.

    Thank you for the help.

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: How do you set a variable to equal the value of a cell?

    You're welcome, glad to help out and thanks for the feedback. Most likely your workbook has several sheets. Each sheet would then have an activecell (the last cell you worked on with that sheet). You have to identify which activecell you are refering too, so you need to activate the sheet when you used activecell.

  9. #9
    Registered User
    Join Date
    07-08-2013
    Location
    Fort Wayne, IN
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: How do you set a variable to equal the value of a cell?

    I see, thanks again for the help - I'm nearly finished with this macro now!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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